From 53fd8328bcc6520b75412c093689d421a3249274 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sat, 9 Nov 2019 15:20:36 +0100 Subject: [PATCH 001/833] add certificate if present on document folder --- .../core/modules/facture/doc/pdf_crabe.modules.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8ee898b5a4e..986b0de2b88 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -357,6 +357,20 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + $cert=file_get_contents(DOL_DATA_ROOT."/users/".$user->id."/certificates/signature.crt"); + // si l'utilisateur n'a pas de certificat, on prend le certificat + if (!$cert) + $cert=file_get_contents(DOL_DATA_ROOT."/mycompany/certificates/signature.crt"); + if ($cert) { + $info = array( + 'Name' => $this->emetteur->name, + 'Location' => getCountry($this->emetteur->country_code, 0), + 'Reason' => 'FACTURE', + 'ContactInfo' => $this->emetteur->email + ); + $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info); + } + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Set $this->atleastonediscount if you have at least one discount From 6acf10c0d43487816ee9d434b298017e1d1bcedf Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 19 Feb 2020 11:54:55 +0100 Subject: [PATCH 002/833] extend retained warranty to be available for all invoices --- htdocs/admin/facture_situation.php | 4 +- htdocs/compta/facture/card.php | 247 ++++++++++-------- htdocs/compta/facture/class/facture.class.php | 49 +++- htdocs/compta/facture/list.php | 4 +- .../facture/doc/pdf_sponge.modules.php | 57 ++-- .../install/mysql/migration/11.0.0-12.0.0.sql | 4 +- htdocs/langs/en_US/bills.lang | 2 + 7 files changed, 204 insertions(+), 163 deletions(-) diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index 408b762358e..aced29bc125 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -96,7 +96,9 @@ print "\n"; _printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices')); _printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote')); -_printOnOff('INVOICE_USE_SITUATION_RETAINED_WARRANTY', $langs->trans('Retainedwarranty')); +_printOnOff('INVOICE_USE_RETAINED_WARRANTY',$langs->trans('Retainedwarranty')); +_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION',$langs->trans('RetainedwarrantyOnlyForSituation')); +_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL',$langs->trans('RetainedwarrantyOnlyForSituationFinal')); $metas = array( 'type' => 'number', diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5038079085b..593e33734c5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -136,7 +136,12 @@ if ($user->socid) $socid = $user->socid; $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); - +// retained warranty invoice available type +if(empty($conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION)) { + $RetainedWarrantyInvoiceAvailableType = array( Facture::TYPE_SITUATION, Facture::TYPE_STANDARD); +} else { + $RetainedWarrantyInvoiceAvailableType = array( Facture::TYPE_SITUATION ); +} /* * Actions @@ -1308,18 +1313,17 @@ if (empty($reshook)) $object->situation_counter = 1; $object->situation_final = 0; $object->situation_cycle_ref = $object->newCycle(); - - - $object->retained_warranty = GETPOST('retained_warranty', 'int'); - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); } + $object->retained_warranty = GETPOST('retained_warranty', 'int'); + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){ + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + $object->fetch_thirdparty(); // If creation from another object of another module (Example: origin=propal, originid=1) @@ -1714,6 +1718,23 @@ if (empty($reshook)) $object->origin = $origin; $object->origin_id = $originid; + // retained warranty + if(!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) + { + $retained_warranty = GETPOST('retained_warranty'); + if(price2num($retained_warranty) > 0) + { + $object->retained_warranty = price2num($retained_warranty); + } + + if(GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) + { + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + } + + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + } + foreach ($object->lines as $i => &$line) { $line->origin = $object->origin; @@ -3309,40 +3330,41 @@ if ($action == 'create') $form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id'); print ''; - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - if ($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { - $rwStyle = 'display:none;'; - if (GETPOST('type', 'int') == Facture::TYPE_SITUATION) { - $rwStyle = ''; - } - $retained_warranty = GETPOST('retained_warranty', 'int'); - $retained_warranty = !empty($retained_warranty) ? $retained_warranty : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT; - print ''.$langs->trans('RetainedWarranty').''; - print '%'; + if($conf->global->INVOICE_USE_RETAINED_WARRANTY){ - // Retained warranty payment term - print ''.$langs->trans('PaymentConditionsShortRetainedWarranty').''; - $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); - print ''; + $rwStyle = 'display:none;'; + if(in_array(GETPOST('type', 'int'), $RetainedWarrantyInvoiceAvailableType)){ + $rwStyle = ''; + } - print ''; - } + + $retained_warranty = GETPOST('retained_warranty', 'int'); + $retained_warranty = !empty($retained_warranty)?$retained_warranty:$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT; + print '' . $langs->trans('RetainedWarranty') . ''; + print '%'; + + // Retained warranty payment term + print '' . $langs->trans('PaymentConditionsShortRetainedWarranty') . ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); + print ''; + + print ''; } // Payment mode @@ -4243,89 +4265,82 @@ elseif ($id > 0 || !empty($ref)) print ''; } - $displayWarranty = false; - if (($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)))) - { - // Check if this situation invoice is 100% for real - if (!empty($object->situation_final) && !empty($object->lines)) { - $displayWarranty = true; - foreach ($object->lines as $i => $line) { - if ($line->product_type < 2 && $line->situation_percent < 100) { - $displayWarranty = false; - break; - } - } - } + if(!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - // Retained Warranty - print ''; - print ''; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { - print ''; - } + $displayWarranty = true; + if(!in_array($object->type, $RetainedWarrantyInvoiceAvailableType) && empty($object->retained_warranty)){ + $displayWarranty = false; + } - print '
'; - print $langs->trans('RetainedWarranty'); - print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; - print ''; - if ($action == 'editretainedwarranty') - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - } - else - { - print price($object->retained_warranty).'%'; - } - print ''; + if($displayWarranty) + { - // Retained warranty payment term - print ''; - print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { - print ''; - } + // Retained Warranty + print '
'; - print $langs->trans('PaymentConditionsShortRetainedWarranty'); - print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; + print ''; + if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { + print ''; + } - print '
'; + print $langs->trans('RetainedWarranty'); + print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; - print '
'; - $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); - if ($object->date > $defaultDate) { - $defaultDate = $object->date; - } + print '
'; + print ''; + if ($action == 'editretainedwarranty') + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + } + else + { + print price($object->retained_warranty).'%'; + } + print ''; - if ($action == 'editretainedwarrantypaymentterms') - { - //date('Y-m-d',$object->date_lim_reglement) - print '
'; - print ''; - print ''; - $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); - print ''; - print '
'; - } - else - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); - if (!$displayWarranty) { - print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); - } - } - print ''; + // Retained warranty payment term + print ''; + print ''; + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + print ''; + } + print '
'; + print $langs->trans('PaymentConditionsShortRetainedWarranty'); + print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; + print ''; + $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); + if ($object->date > $defaultDate) { + $defaultDate = $object->date; + } + + if ($action == 'editretainedwarrantypaymentterms') + { + //date('Y-m-d',$object->date_lim_reglement) + print '
'; + print ''; + print ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); + print ''; + print '
'; + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); + if (!$displayWarranty) { + print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); + } + } + print ''; - if ($displayWarranty) - { // Retained Warranty payment date limit print ''; print '\n"; _printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices')); _printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote')); -_printOnOff('INVOICE_USE_RETAINED_WARRANTY',$langs->trans('Retainedwarranty')); -_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION',$langs->trans('RetainedwarrantyOnlyForSituation')); -_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL',$langs->trans('RetainedwarrantyOnlyForSituationFinal')); +_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty')); +_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation')); +_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL', $langs->trans('RetainedwarrantyOnlyForSituationFinal')); $metas = array( 'type' => 'number', diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 593e33734c5..75e56b580a4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3332,7 +3332,6 @@ if ($action == 'create') if($conf->global->INVOICE_USE_RETAINED_WARRANTY){ - $rwStyle = 'display:none;'; if(in_array(GETPOST('type', 'int'), $RetainedWarrantyInvoiceAvailableType)){ $rwStyle = ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 30f3867a843..135d30ef576 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4610,7 +4610,8 @@ class Facture extends CommonInvoice * Currently used for documents generation : to know if retained warranty need to be displayed * @return bool */ - function displayRetainedWarranty(){ + function displayRetainedWarranty() + { global $conf; // TODO : add a flag on invoices to store this conf : USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL From d65c17df7dd323c3743f68a733699c283d8040a6 Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 19 Feb 2020 12:30:52 +0100 Subject: [PATCH 004/833] Add retained warranty for all invoice for crabe PDF --- .../modules/facture/doc/pdf_crabe.modules.php | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6e8918920a6..7dc9aa245e9 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1377,47 +1377,33 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); // Retained warranty - if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty)))) + if ($object->displayRetainedWarranty()) { - $displayWarranty = false; + $pdf->SetTextColor(40, 40, 40); + $pdf->SetFillColor(255, 255, 255); - // Check if this situation invoice is 100% for real - if (!empty($object->lines)) { - $displayWarranty = true; - foreach ($object->lines as $i => $line) { - if ($line->product_type < 2 && $line->situation_percent < 100) { - $displayWarranty = false; - break; - } - } - } + $retainedWarranty = $object->getRetainedWarrantyAmount(); + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; - if ($displayWarranty) { - $pdf->SetTextColor(40, 40, 40); - $pdf->SetFillColor(255, 255, 255); + // Billed - retained warranty + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); - $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; - $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1); - // Billed - retained warranty - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); + // retained warranty + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1); + $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)'; + $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - // retained warranty - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1); - $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)'; - $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1); - } } } } From 729048a1131f7e5402edc01d5cc8f01dfde79c31 Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 19 Feb 2020 12:33:36 +0100 Subject: [PATCH 005/833] Fix langs --- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 5ab59275666..82a55fbf319 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1674,7 +1674,7 @@ class pdf_sponge extends ModelePDFFactures // Billed - retained warranty $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1); @@ -1683,8 +1683,8 @@ class pdf_sponge extends ModelePDFFactures $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)'; - $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; + $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)'; + $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); From 8777033bff422bbfa2e301c6181b945bb1378214 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 20 Feb 2020 22:18:34 +0100 Subject: [PATCH 006/833] Update list.php --- htdocs/commande/list.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 845bc4603cd..877eb1becd6 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -75,6 +75,7 @@ $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); +$search_warehouse = GETPOST('search_warehouse', 'int'); $search_login = GETPOST('search_login', 'alpha'); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); @@ -328,7 +329,8 @@ if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$s if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); -if ($search_login) $sql .= natural_search("u.login", $search_login); +if ($search_warehouse != '') $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); +if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); if ($search_project != '') $sql .= natural_search("p.title", $search_project); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); @@ -424,7 +426,8 @@ if ($resql) if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); - if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_warehouse != '') $param .= '&search_warehouse='.urlencode($search_warehouse); + if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); if ($search_town != '') $param .= '&search_town='.urlencode($search_town); if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); @@ -573,6 +576,14 @@ if ($resql) $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); $moreforfilter .= ''; } + if (!empty($conf->expedition->enabled)){ + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Warehouse').': '; + $moreforfilter .= $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1); + $moreforfilter .= '
'; + } $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; From 4865e34cc2610dd66561bc838d160306cab8ad5c Mon Sep 17 00:00:00 2001 From: ATM john Date: Tue, 25 Feb 2020 23:02:13 +0100 Subject: [PATCH 007/833] fix missing visibility --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 24d4b40d339..30a607afc0a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4713,7 +4713,7 @@ class Facture extends CommonInvoice * Currently used for documents generation : to know if retained warranty need to be displayed * @return bool */ - function displayRetainedWarranty() + public function displayRetainedWarranty() { global $conf; From 74ac69fc5a27768c5644865933b3980109d483f6 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 27 Feb 2020 09:16:15 +0100 Subject: [PATCH 008/833] Add Entity in list_product_fournisseur_price() Select too the entity value to add const NOTMODIFYOTHERENTITYFOURNPRICE --- .../fourn/class/fournisseur.product.class.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 9f49fb31b83..f11f88464f3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1,12 +1,13 @@ - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2009-2014 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2020 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -590,7 +591,7 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; + $sql.= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; $sql.= " pfp.barcode, pfp.fk_barcode_type"; @@ -616,6 +617,7 @@ class ProductFournisseur extends Product $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; $prodfourn->product_fourn_id = $record["product_fourn_id"]; + $prodfourn->product_fourn_entity = $record["entity"]; $prodfourn->fourn_ref = $record["ref_fourn"]; $prodfourn->ref_supplier = $record["ref_fourn"]; $prodfourn->desc_supplier = $record["desc_fourn"]; From 84764771373f06b9fd62ea691ddac377bbdfe848 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 27 Feb 2020 09:19:39 +0100 Subject: [PATCH 009/833] add const NOTMODIFYOTHERENTITYFOURNPRICE if const NOTMODIFYOTHERENTITYFOURNPRICE, can't modify other shared fourn prices. --- htdocs/product/fournisseurs.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 0bda7d44564..797f350627e 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -1,14 +1,15 @@ - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2012 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2014 Ion Agorria - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2014 Ion Agorria + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2020 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -933,7 +934,14 @@ SCRIPT; // Modify-Remove print '
\n"; +print '\n"; + $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 60854bf2407..d80e593f3cb 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -318,7 +318,23 @@ if ($action == "addline") } } - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0); + $idoflineadded = 0; + if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) { + foreach ($invoice->lines as $line) { + if ($line->product_ref == $prod->ref) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty+1, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if ($result < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } else { + $idoflineadded = $line->id; + } + break; + } + } + } + if ($idoflineadded <= 0) { + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0); + } $invoice->fetch($placeid); } From a6f8608ffd8f96408bde8a147627b81b282cf030 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 11:09:18 +0100 Subject: [PATCH 018/833] Fix when undefined key --- htdocs/core/customreports.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index b5379ef911b..753e30650ad 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -213,7 +213,7 @@ if ($action == 'viewgraph') { } } -// Get all possible values of fields when a 'group by' is set and save this into $arrayofvaluesforgroupby +// Get all possible values of fields when a 'group by' is set, and save this into $arrayofvaluesforgroupby if (is_array($search_groupby) && count($search_groupby)) { foreach($search_groupby as $gkey => $gval) { $gvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $gval); @@ -262,6 +262,8 @@ if (is_array($search_groupby) && count($search_groupby)) { } if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; + if (is_null($valuetranslated)) $valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey"); + $valuetranslated = $langs->trans($valuetranslated); } $arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated; From d6a35db7543ef79e0989762963f3491460c1509c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 11:13:50 +0100 Subject: [PATCH 019/833] Look and feel v12 --- htdocs/core/class/dolgraph.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 3f3f905166e..8edad43dce0 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -743,7 +743,7 @@ class DolGraph if (!empty($this->shownographyet)) { $this->stringtoshow .= '
'; - $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'
'; + $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'...
'; return; } @@ -1033,7 +1033,7 @@ class DolGraph if (!empty($this->shownographyet)) { $this->stringtoshow .= '
'; - $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'
'; + $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'...
'; return; } @@ -1313,11 +1313,11 @@ class DolGraph if ($shownographyet) { $s = '
'; - $s .= '
'; + $s .= '
'; if (is_numeric($shownographyet)) { - $s .= $langs->trans("NotEnoughDataYet"); + $s .= $langs->trans("NotEnoughDataYet").'...'; } else { - $s .= $shownographyet; + $s .= $shownographyet.'...'; } $s .= '
'; return $s; From 310bdf6062ae3403d8aeeeb2d9aac3279cd71d6f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 12 Mar 2020 11:55:26 +0100 Subject: [PATCH 020/833] NEW : accounting export LD compta version 10 --- .../class/accountancyexport.class.php | 269 +++++++++++++++++- htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 269 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 847aa3ef47e..6d2398f08d2 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -54,6 +54,7 @@ class AccountancyExport public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_LDCOMPTA = 110; + public static $EXPORT_TYPE_LDCOMPTA10 = 120; public static $EXPORT_TYPE_FEC = 1000; @@ -110,8 +111,9 @@ class AccountancyExport self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), + self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), - self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), + self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), ); ksort($listofexporttypes, SORT_NUMERIC); @@ -140,6 +142,7 @@ class AccountancyExport self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -201,6 +204,10 @@ class AccountancyExport self::$EXPORT_TYPE_LDCOMPTA => array( 'label' => $langs->trans('Modelcsv_LDCompta'), 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), + self::$EXPORT_TYPE_LDCOMPTA10 => array( + 'label' => $langs->trans('Modelcsv_LDCompta10'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), @@ -280,6 +287,9 @@ class AccountancyExport case self::$EXPORT_TYPE_LDCOMPTA : $this->exportLDCompta($TData); break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; case self::$EXPORT_TYPE_FEC : $this->exportFEC($TData); break; @@ -1051,6 +1061,263 @@ class AccountancyExport } } + /** + * Export format : LD Compta version 10 & higher + * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf + * + * @param array $objectLines data + * + * @return void + */ + public function exportLDCompta10($objectLines) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + + $separator = ';'; + $end_line = "\r\n"; + $last_codeinvoice = ''; + + foreach ($objectLines as $line) { + + // TYPE C + if($last_codeinvoice != $line->doc_ref){ + + //recherche societe en fonction de son code client + $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code ."'"; + $resql = $this->db->query($sql); + + if($resql && $this->db->num_rows($resql)>0) + { + $soc = $this->db->fetch_object($resql); + + $address = str_replace(array("\t", "\n", "\r"), " ", $soc->address); + + $type_enregistrement = 'C'; + print $type_enregistrement.$separator; + //NOCL + print $soc->code_client.$separator; + //NMCM + print $separator; + //LIBI + print $separator; + //TITR + print getFormeJuridiqueLabel($soc->fk_forme_juridique).$separator; + //RSSO + print $soc->nom.$separator; + //CAD1 + print substr($address, 0, 40).$separator; + //CAD2 + print substr($address, 41, 40).$separator; + //CAD3 + print substr($address, 82, 40).$separator; + //COPO + print $soc->zip.$separator; + //BUDI + print substr($soc->town, 0, 40).$separator; + //CPAY + print $separator; + //PAYS + print substr(getCountry($soc->fk_pays), 0, 40).$separator; + //NTEL + print $soc->phone.$separator; + //TLEX + print $separator; + //TLPO + print $separator; + //TLCY + print $separator; + //NINT + print $separator; + //COMM + print $separator; + //SIRE + print $soc->siret.$separator; + //RIBP + print $separator; + //DOBQ + print $separator; + //IBBQ + print $separator; + //COBQ + print $separator; + //GUBQ + print $separator; + //CPBQ + print $separator; + //CLBQ + print $separator; + //BIBQ + print $separator; + //MOPM + print $separator; + //DJPM + print $separator; + //DMPM + print $separator; + //REFM + print $separator; + //SLVA + print $separator; + //PLCR + print $separator; + //ECFI + print $separator; + //CREP + print $separator; + //NREP + print $separator; + //TREP + print $separator; + //MREP + print $separator; + //GRRE + print $separator; + //LTTA + print $separator; + //CACT + print $separator; + //CODV + print $separator; + //GRTR + print $separator; + //NOFP + print $separator; + //BQAF + print $separator; + //BONP + print $separator; + //CESC + print $separator; + + print $end_line; + } + } + + $date_document = dol_print_date($line->doc_date, '%Y%m%d'); + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + + // TYPE E + $type_enregistrement = 'E'; // For write movement + print $type_enregistrement.$separator; + // JNAL + print substr($line->code_journal, 0, 2).$separator; + // NECR + print $line->id.$separator; + // NPIE + print $line->piece_num.$separator; + // DATP + print $date_document.$separator; + // LIBE + print dol_trunc($line->label_operation,25,'right','UTF-8',1).$separator; + // DATH + print $date_lim_reglement.$separator; + // CNPI + if ($line->doc_type == 'supplier_invoice') { + if ($line->montant < 0) { + $nature_piece = 'AF'; + } else { + $nature_piece = 'FF'; + } + } elseif ($line->doc_type == 'customer_invoice') { + if ($line->montant < 0) { + $nature_piece = 'AC'; + } else { + $nature_piece = 'FC'; + } + } else { + $nature_piece = ''; + } + print $nature_piece.$separator; + // RACI + // if (! empty($line->subledger_account)) { + // if ($line->doc_type == 'supplier_invoice') { + // $racine_subledger_account = '40'; + // } elseif ($line->doc_type == 'customer_invoice') { + // $racine_subledger_account = '41'; + // } else { + // $racine_subledger_account = ''; + // } + // } else { + $racine_subledger_account = ''; // for records of type E leave this field blank + // } + + print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead + // MONT + print price(abs($line->montant), 0, '', 1, 2).$separator; + // CODC + print $line->sens.$separator; + // CPTG + print length_accountg($line->numero_compte).$separator; + // DATE + print $date_document.$separator; + // CLET + print $line->lettering_code.$separator; + // DATL + print $line->date_lettering.$separator; + // CPTA + if (!empty($line->subledger_account)) { + print length_accounta($line->subledger_account).$separator; + } else { + print $separator; + } + // CNAT + if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) { + print 'F'.$separator; + } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) { + print 'C'.$separator; + } else { + print $separator; + } + // SECT + print $separator; + // CTRE + print $separator; + // NORL + print $separator; + // DATV + print $separator; + // REFD + print $line->doc_ref.$separator; + // NECA + print '0'.$separator; + // CSEC + print $separator; + // CAFF + print $separator; + // CDES + print $separator; + // QTUE + print '0'.$separator; + // MTDV + print $separator; + // CODV + print '0'.$separator; + // TXDV + print $separator; + // MOPM + print $separator; + // BONP + print $separator; + // BQAF + print $separator; + // ECES + print $separator; + // TXTL + print $separator; + // ECRM + print $separator; + // DATK + print $separator; + // HEUK + print $separator; + + print $end_line; + + $last_codeinvoice = $line->doc_ref; + } + } + /** * Export format : Charlemagne * diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 7ae71d281ae..1fb40c399c4 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -313,6 +313,7 @@ Modelcsv_ebp=Export for EBP Modelcsv_cogilog=Export for Cogilog Modelcsv_agiris=Export for Agiris Modelcsv_LDCompta=Export for LD Compta (v9 & higher) (Test) +Modelcsv_LDCompta10=Export for LD Compta (v10 & higher) Modelcsv_openconcerto=Export for OpenConcerto (Test) Modelcsv_configurable=Export CSV Configurable Modelcsv_FEC=Export FEC From 85c8296e1050560dc105df354f65b4417e1d8942 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 12 Mar 2020 10:59:08 +0000 Subject: [PATCH 021/833] Fixing style errors. --- htdocs/accountancy/class/accountancyexport.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 6d2398f08d2..7a624b0bec5 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1078,10 +1078,8 @@ class AccountancyExport $last_codeinvoice = ''; foreach ($objectLines as $line) { - // TYPE C if($last_codeinvoice != $line->doc_ref){ - //recherche societe en fonction de son code client $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code ."'"; $resql = $this->db->query($sql); @@ -1209,7 +1207,7 @@ class AccountancyExport // DATP print $date_document.$separator; // LIBE - print dol_trunc($line->label_operation,25,'right','UTF-8',1).$separator; + print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator; // DATH print $date_lim_reglement.$separator; // CNPI From c1e5178eebbf03bc950ad50d2ba9feec4e4e43e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:01:40 +0100 Subject: [PATCH 022/833] Doc --- ChangeLog | 40 ++++++++++++++------------- htdocs/core/class/html.form.class.php | 8 ++++-- htdocs/theme/eldy/global.inc.php | 14 ++++++++-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 279fc01cfa8..0483767ac50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,27 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 12.0.0 compared to 11.0.0 ***** +For Users: +NEW: Module MO (Manufacturing Order) is available as stable module. + +For Developers or integrators: + + + +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* PHP 5.5 is no more supported. Minimum PHP is now 5.6+. +* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests + with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing + the HTML into content (in such a case, sanitize data later) +* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. +* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced + by a "_" automatically when a reference (with a custom numbering mask that use it) is generated. + + ***** ChangeLog for 11.0.2 compared to 11.0.1 ***** FIX: #10309 FIX: #13110 @@ -66,25 +87,6 @@ FIX: Visualization rights correction on last modified contacts box. FIX: Vulnerability in module from modulebuilder. FIX: Vulnerability reported by code16 -***** ChangeLog for 12.0.0 compared to 11.0.0 ***** -For Users: -NEW: Module MO (Manufacturing Order) is available as stable module. - -For Developers or integrators: - - - -WARNING: - -Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* PHP 5.5 is no more supported. Minimum PHP is now 5.6+. -* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests - with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing - the HTML into content (in such a case, sanitize data later) -* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. -* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced - by a "_" automatically when a reference is generated. - ***** ChangeLog for 11.0.1 compared to 11.0.0 ***** FIX: advanced target emailing sql and ergonomy. FIX: After import of a website template, home page was not set. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0db01a84656..e2e1444b018 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8077,9 +8077,13 @@ class Form $ret .= $langs->trans("Filters"); $ret .= ''; //$ret .= ''; - $ret .= '
'; - $ret .= ''; + $ret .= '
'; + $texttoshow = '
'.$langs->trans("Search").'
'; + + $ret .= '
'.$texttoshow.'
'; $ret .= '
'; + $ret .= ''; + // For compatibility with forms that show themself the search criteria in addition of this component, we output the fields foreach ($arrayofcriterias as $criterias) { foreach ($criterias as $criteriafamilykey => $criteriafamilyval) { if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 97458577f59..4fb723e7291 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -702,14 +702,24 @@ div.divsearchfield { -webkit-flex-flow: row wrap; flex-flow: row wrap; background: #fff; - padding: 3px; + padding-top: 3px; + padding-bottom: 3px; + padding-left: 10px; + padding-right: 10px; + border-bottom: solid 1px rgba(0,0,0,.2); + height: 24px; } -.search_component_params_input, .search_component_params_input:focus { +.search_component_searchtext { + padding-top: 2px; +} +.search_component_params_text, .search_component_params_text:focus { border-bottom: none; width: auto; margin: 0 !important; padding: 3px; } + + browser->layout == 'phone') { From e7ce9c16cbf88a296ac82d315ce0ca362aebe78e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:15:16 +0100 Subject: [PATCH 023/833] FIX #13313 --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 4e636f3d9cf..510bb888813 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -761,7 +761,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); - var pbqup = parseInt($('option:selected', this).attr('data-pbqup')); + var pbqup = parseFloat($('option:selected', this).attr('data-pbqup')); var pbqbase = $('option:selected', this).attr('data-pbqbase'); var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); From ad22820872c26ad99eee30c2bebaeb77f2dcea4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:15:16 +0100 Subject: [PATCH 024/833] FIX #13313 --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 7cc472e987e..160d323a2c2 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -761,7 +761,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); - var pbqup = parseInt($('option:selected', this).attr('data-pbqup')); + var pbqup = parseFloat($('option:selected', this).attr('data-pbqup')); var pbqbase = $('option:selected', this).attr('data-pbqbase'); var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); From 5dc403cb664fe3c1397fc3cbb9b7469dfc816466 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:19:24 +0100 Subject: [PATCH 025/833] FIX #13304 --- htdocs/expensereport/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index a05fd1393bb..03cafb6b60d 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -277,7 +277,9 @@ $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.tota $sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; // Add fields from extrafields -foreach ($extrafields->attributes['expensereport']['type'] as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (is_array($extrafields->attributes['expensereport']['type'])) { + foreach ($extrafields->attributes['expensereport']['type'] as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook From c5a4adf63fc61ad16d4f27f3c076cdf8591dd0e8 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 12 Mar 2020 12:25:19 +0100 Subject: [PATCH 026/833] update doc --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 6d2398f08d2..f72cd9a8ee7 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -931,7 +931,7 @@ class AccountancyExport /** * Export format : LD Compta version 9 & higher - * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf + * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf * * @param array $objectLines data * From 31865d7ae59f169fdf2519422027c1b21bb68fd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:39:21 +0100 Subject: [PATCH 027/833] Fix doc --- htdocs/product/class/product.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 30e1d48cd18..b4070653530 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -139,10 +139,10 @@ class Product extends CommonObject */ public $price_min_ttc; - /* - * Base price ('TTC' for price including tax or 'HT' for net price) - * @var float - */ + /** + * Base price ('TTC' for price including tax or 'HT' for net price) + * @var string + */ public $price_base_type; //! Arrays for multiprices From dfe947885cba371b336f28316a3e7a9f4c84a68e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:40:28 +0100 Subject: [PATCH 028/833] FIX params of setEventMessage($langs->trans('ErrorProductClone')... --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e80ea9e6984..01da1eb741f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -545,7 +545,7 @@ if (empty($reshook)) if ($result < 1) { $db->rollback(); - setEventMessage($langs->trans('ErrorProductClone'), null, 'errors'); + setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); exit; } From f38134e44d04e18da5a7765397938e6fb806bac9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 12:42:34 +0100 Subject: [PATCH 029/833] Fix non transversable var --- htdocs/product/card.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9c315591903..7953bddb2fd 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1601,8 +1601,10 @@ else $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT); $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + if (is_array($cats)) { + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print ""; From 325d635c48fcc44aead95edae3bdcf025f4fb769 Mon Sep 17 00:00:00 2001 From: simicar29 <53998265+simicar29@users.noreply.github.com> Date: Thu, 12 Mar 2020 12:43:06 +0100 Subject: [PATCH 030/833] Load line extrafields when fetching supplier invoice PR to load extrafield values of lines when fetchinf supplier invoice. --- htdocs/fourn/class/fournisseur.facture.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8b07b0fbebe..e58410fb0f0 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -859,7 +859,10 @@ class FactureFournisseur extends CommonInvoice $line->multicurrency_total_tva = $obj->multicurrency_total_tva; $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->lines[$i] = $line; + // Extra fields + $line->fetch_optionals(); + + $this->lines[$i] = $line; $i++; } From f413ce6aacc02468576500c53df58d6a3a13016d Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Thu, 12 Mar 2020 11:45:44 +0000 Subject: [PATCH 031/833] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/admin/defaultaccounts.php | 22 +- htdocs/accountancy/admin/productaccount.php | 210 +++--- htdocs/accountancy/bookkeeping/list.php | 28 +- htdocs/accountancy/supplier/list.php | 6 +- htdocs/adherents/class/adherent.class.php | 460 ++++++------- htdocs/admin/ihm.php | 120 ++-- .../comm/propal/class/api_proposals.class.php | 170 ++--- htdocs/comm/propal/class/propal.class.php | 6 +- .../comm/propal/class/propalestats.class.php | 112 ++-- htdocs/comm/propal/list.php | 14 +- htdocs/commande/class/api_orders.class.php | 160 ++--- htdocs/commande/class/commande.class.php | 4 +- htdocs/commande/class/commandestats.class.php | 96 +-- htdocs/commande/list.php | 6 +- htdocs/compta/accounting-files.php | 24 +- htdocs/compta/bank/list.php | 124 ++-- htdocs/compta/deplacement/index.php | 68 +- htdocs/compta/facture/card.php | 8 +- htdocs/compta/facture/class/facture.class.php | 16 +- .../facture/class/facturestats.class.php | 104 +-- htdocs/compta/facture/list.php | 6 +- htdocs/core/actions_extrafields.inc.php | 176 ++--- .../boxes/box_graph_product_distribution.php | 6 +- htdocs/core/class/canvas.class.php | 30 +- .../core/class/commondocgenerator.class.php | 266 ++++---- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/dolgraph.class.php | 62 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formother.class.php | 102 +-- htdocs/core/class/stats.class.php | 206 +++--- htdocs/core/customreports.php | 42 +- htdocs/core/lib/functions.lib.php | 8 +- htdocs/core/lib/security.lib.php | 4 +- htdocs/core/lib/website.lib.php | 212 +++--- htdocs/core/lib/website2.lib.php | 2 +- htdocs/core/modules/modProduct.class.php | 288 ++++---- htdocs/core/modules/modService.class.php | 288 ++++---- htdocs/core/tpl/admin_extrafields_add.tpl.php | 22 +- .../core/tpl/admin_extrafields_edit.tpl.php | 74 +-- .../core/tpl/admin_extrafields_view.tpl.php | 18 +- htdocs/core/tpl/contacts.tpl.php | 32 +- htdocs/core/tpl/extrafields_add.tpl.php | 4 +- htdocs/core/tpl/extrafields_edit.tpl.php | 8 +- htdocs/core/tpl/objectline_create.tpl.php | 4 +- .../interface_20_all_Logevents.class.php | 80 +-- ...terface_50_modAgenda_ActionsAuto.class.php | 620 +++++++++--------- htdocs/don/list.php | 72 +- .../class/emailcollector.class.php | 30 +- htdocs/expedition/class/expedition.class.php | 304 ++++----- htdocs/expensereport/payment/payment.php | 70 +- htdocs/fichinter/class/fichinter.class.php | 4 +- .../fichinter/class/fichinterstats.class.php | 82 +-- htdocs/fourn/commande/list.php | 92 +-- htdocs/fourn/facture/list.php | 174 ++--- .../template/class/myobject.class.php | 18 +- htdocs/mrp/index.php | 46 +- htdocs/product/class/product.class.php | 2 +- htdocs/product/stats/commande.php | 122 ++-- htdocs/product/stats/facture.php | 134 ++-- .../canvas/actions_card_common.class.php | 224 +++---- htdocs/societe/class/societe.class.php | 8 +- htdocs/supplier_proposal/list.php | 108 +-- htdocs/takepos/admin/setup.php | 2 +- htdocs/takepos/admin/terminal.php | 12 +- htdocs/takepos/invoice.php | 40 +- htdocs/takepos/pay.php | 38 +- htdocs/takepos/reduction.php | 2 +- htdocs/takepos/takepos.php | 6 +- .../website/migrate_news_joomla2dolibarr.php | 12 +- 69 files changed, 2962 insertions(+), 2962 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 43dc3ccea67..ad22a88f415 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -46,13 +46,13 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); -$list_account_main = array ( +$list_account_main = array( 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); -$list_account = array (); +$list_account = array(); $list_account[] = '---Product---'; $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { @@ -120,25 +120,25 @@ if ($action == 'update') { foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } foreach ($list_account as $constname) { - $reg=array(); + $reg = array(); if (preg_match('/---(.*)---/', $constname, $reg)) { // This is a separator continue; } $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -190,7 +190,7 @@ foreach ($list_account_main as $key) { foreach ($list_account as $key) { - $reg=array(); + $reg = array(); if (preg_match('/---(.*)---/', $key, $reg)) { print '
'; } @@ -198,9 +198,9 @@ foreach ($list_account as $key) { print ''; // Param $label = $langs->trans($key); - print ''; + print ''; // Value - print ''; print ''; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 6946f8df831..fb909ecb7ad 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -59,7 +59,7 @@ $search_label = GETPOST('search_label', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); $search_current_account = GETPOST('search_current_account', 'alpha'); $search_current_account_valid = GETPOST('search_current_account_valid', 'alpha'); -if ($search_current_account_valid == '') $search_current_account_valid='withoutvalidaccount'; +if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount'; $search_onsell = GETPOST('search_onsell', 'alpha'); $search_onpurchase = GETPOST('search_onpurchase', 'alpha'); @@ -67,9 +67,9 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha'); -if (empty($accounting_product_mode)) $accounting_product_mode='ACCOUNTANCY_SELL'; +if (empty($accounting_product_mode)) $accounting_product_mode = 'ACCOUNTANCY_SELL'; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -224,56 +224,56 @@ $aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_P $aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1); $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); -$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_intra = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_export = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_export = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_intra = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_export = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_export = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_intra = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_export = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_export = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servsell_intra = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servsell_export = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodsell_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodsell_export = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); llxHeader('', $langs->trans("ProductsBinding")); $pcgverid = $conf->global->CHARTOFACCOUNTS; $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); -if (empty($pcgvercode)) $pcgvercode=$pcgverid; +if (empty($pcgvercode)) $pcgvercode = $pcgverid; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,"; -$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; -$sql.= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; -$sql.= " p.tms, p.fk_product_type as product_type,"; -$sql.= " aa.rowid as aaid"; -$sql.= " FROM " . MAIN_DB_PREFIX . "product as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; +$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; +$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +$sql .= " p.tms, p.fk_product_type as product_type,"; +$sql .= " aa.rowid as aaid"; +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $sql.=" p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $sql.=" p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql.=" p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } else { - $sql.=" p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; + $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } -$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy", $search_current_account); @@ -319,8 +319,8 @@ if (strlen(trim($search_label))) { if (strlen(trim($search_desc))) { $sql .= natural_search("p.description", $search_desc); } -if ($search_onsell != '' && $search_onsell != '-1') $sql.= natural_search('p.tosell', $search_onsell, 1); -if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql.= natural_search('p.tobuy', $search_onpurchase, 1); +if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1); +if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1); $sql .= $db->order($sortfield, $sortorder); @@ -367,60 +367,60 @@ if ($result) print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print '
'; - print ''.$langs->trans("InitAccountancyDesc") . '
'; + print ''.$langs->trans("InitAccountancyDesc").'
'; print '
'; // Select mode print '
'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cb2bf087652..30f3867a843 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -297,9 +297,9 @@ class Facture extends CommonInvoice 'situation_cycle_ref' =>array('type'=>'smallint(6)', 'label'=>'Situation cycle ref', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>230), 'situation_counter' =>array('type'=>'smallint(6)', 'label'=>'Situation counter', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>235), 'situation_final' =>array('type'=>'smallint(6)', 'label'=>'Situation final', 'enabled'=>'empty($conf->global->INVOICE_USE_SITUATION) ? 0 : 1', 'visible'=>-1, 'position'=>240), - 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245), - 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250), - 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255), + 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245), + 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250), + 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255), 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermsCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>260), 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermsLocation', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>265), 'date_pointoftax' =>array('type'=>'date', 'label'=>'DatePointOfTax', 'enabled'=>'$conf->global->INVOICE_POINTOFTAX_DATE', 'visible'=>-1, 'position'=>270), @@ -4606,6 +4606,42 @@ class Facture extends CommonInvoice return $hasDelay; } + /** + * Currently used for documents generation : to know if retained warranty need to be displayed + * @return bool + */ + function displayRetainedWarranty(){ + global $conf; + + // TODO : add a flag on invoices to store this conf : USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL + + // note : we dont need to test USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION because if $this->retained_warranty is not empty it's because it was set when this conf was active + + $displayWarranty = false; + if(!empty($this->retained_warranty)) { + $displayWarranty = true; + + if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL)) { + // Check if this situation invoice is 100% for real + $displayWarranty = false; + if (!empty($this->situation_final)) { + $displayWarranty = true; + } elseif (!empty($this->lines) && $this->status == Facture::STATUS_DRAFT) { + // $object->situation_final need validation to be done so this test is need for draft + $displayWarranty = true; + + foreach ($this->lines as $i => $line) { + if ($line->product_type < 2 && $line->situation_percent < 100) { + $displayWarranty = false; + break; + } + } + } + } + } + + return $displayWarranty; + } /** * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) @@ -4621,7 +4657,7 @@ class Facture extends CommonInvoice $retainedWarrantyAmount = 0; // Billed - retained warranty - if ($this->type == Facture::TYPE_SITUATION) + if($this->type == Facture::TYPE_SITUATION && !empty($conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL)) { $displayWarranty = true; // Check if this situation invoice is 100% for real @@ -4659,7 +4695,10 @@ class Facture extends CommonInvoice if ($rounding < 0){ $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - return round($retainedWarrantyAmount, 2); + } + + if($rounding>0){ + return round($retainedWarrantyAmount, $rounding); } return $retainedWarrantyAmount; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b32d82a08cb..dc685c0a893 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -188,7 +188,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) +if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } @@ -1002,7 +1002,7 @@ if ($resql) $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); $facturestatic->note_public = $obj->note_public; $facturestatic->note_private = $obj->note_private; - if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) + if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { $facturestatic->retained_warranty = $obj->retained_warranty; $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index a9d1230fdec..5ab59275666 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1663,51 +1663,32 @@ class pdf_sponge extends ModelePDFFactures // Retained warranty - if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty)))) + if ($object->displayRetainedWarranty()) { - $displayWarranty = false; + $pdf->SetTextColor(40, 40, 40); + $pdf->SetFillColor(255, 255, 255); - // Check if this situation invoice is 100% for real - if (!empty($object->situation_final)) { - $displayWarranty = true; - } - elseif (!empty($object->lines) && $object->status == Facture::STATUS_DRAFT) { - // $object->situation_final need validation to be done so this test is need for draft - $displayWarranty = true; - foreach ($object->lines as $i => $line) { - if ($line->product_type < 2 && $line->situation_percent < 100) { - $displayWarranty = false; - break; - } - } - } + $retainedWarranty = $object->getRetainedWarrantyAmount(); + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; - if ($displayWarranty) { - $pdf->SetTextColor(40, 40, 40); - $pdf->SetFillColor(255, 255, 255); + // Billed - retained warranty + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); - $retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100; - $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1); - // Billed - retained warranty - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); + // retained warranty + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1); + $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)'; + $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - // retained warranty - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)'; - $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1); - } + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1); } } } diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 447630e7eb2..bf641871be9 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -163,4 +163,6 @@ INSERT INTO llx_c_ticket_resolution (code, pos, label, active, use_default, desc INSERT INTO llx_c_ticket_resolution (code, pos, label, active, use_default, description) VALUES('CANCELED', '50', 'Canceled', 1, 0, NULL); INSERT INTO llx_c_ticket_resolution (code, pos, label, active, use_default, description) VALUES('OTHER', '90', 'Other', 1, 0, NULL); -DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__; \ No newline at end of file +DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__; + +UPDATE llx_const SET name = 'INVOICE_USE_RETAINED_WARRANTY' WHERE name = 'INVOICE_USE_SITUATION_RETAINED_WARRANTY' diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 6d7c61784f7..fe33c173cea 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -220,6 +220,8 @@ UseSituationInvoices=Allow situation invoice UseSituationInvoicesCreditNote=Allow situation invoice credit note Retainedwarranty=Retained warranty RetainedwarrantyDefaultPercent=Retained warranty default percent +RetainedwarrantyOnlyForSituation=Make "retained warranty" available only for situation invoices +RetainedwarrantyOnlyForSituationFinal=On situation invoices the global "retained warranty" deduction is applied only on the final situation ToPayOn=To pay on %s toPayOn=to pay on %s RetainedWarranty=Retained Warranty From 028566616d5f4210383afa249ad338f8e0586a25 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 19 Feb 2020 11:07:42 +0000 Subject: [PATCH 003/833] Fixing style errors. --- htdocs/admin/facture_situation.php | 6 +++--- htdocs/compta/facture/card.php | 1 - htdocs/compta/facture/class/facture.class.php | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index aced29bc125..0a4c36cb8a8 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -96,9 +96,9 @@ print "
'; - if ($usercancreate) + + if (!empty($conf->global->NOTMODIFYOTHERENTITYFOURNPRICE) && $productfourn->product_fourn_entity!=$conf->entity) { + $canmodifyotherentityfournprice = 0; + }else{ + $canmodifyotherentityfournprice = 1; + } + + if ($usercancreate && $canmodifyotherentityfournprice == 1) { print ''.img_edit().""; print '   '; From 5520df4e4fef35deda1384210e0e5846b06a401f Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Mon, 2 Mar 2020 08:25:18 +0100 Subject: [PATCH 010/833] Update list.php --- htdocs/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 877eb1becd6..34730711535 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -576,7 +576,7 @@ if ($resql) $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); $moreforfilter .= ''; } - if (!empty($conf->expedition->enabled)){ + if (!empty($conf->expedition->enabled) && $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER = 1){ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $moreforfilter .= '
'; From dbb80aecd1afb0853d80d474a93ec674f68f0d1a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Mar 2020 15:22:35 +0100 Subject: [PATCH 011/833] Fix line origin and Id when create order from --- htdocs/commande/class/commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b19210f894a..7249973f768 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -951,8 +951,8 @@ class Commande extends CommonOrder $line->label, $line->array_options, $line->fk_unit, - $this->element, - $line->id + $line->origin, + $line->origin_id ); if ($result < 0) { From f40c8ce5075047ef15f03791e32071542bf33bb6 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 11 Mar 2020 17:58:41 +0100 Subject: [PATCH 012/833] fix getentity on comm/card.php --- htdocs/comm/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index d31ed9cb080..fcd3823b0c2 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -751,7 +751,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".$object->id; - $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.entity IN (".getEntity('commande').')'; $sql .= " ORDER BY c.date_commande DESC"; $resql = $db->query($sql); @@ -905,7 +905,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".$object->id; - $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.entity IN (".getEntity('contract').")"; $sql .= " ORDER BY c.datec DESC"; $resql = $db->query($sql); @@ -975,7 +975,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND s.rowid = ".$object->id; - $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.entity IN (".getEntity('intervention').")"; $sql .= " ORDER BY f.tms DESC"; $resql = $db->query($sql); @@ -1044,7 +1044,7 @@ if ($object->id > 0) $sql .= ', s.nom, s.rowid as socid'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; $sql .= ' f.suspended, f.date_when,'; From 6edaa7ac1162aa988d5023a439cde6d7b09b1990 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 11 Mar 2020 18:00:35 +0100 Subject: [PATCH 013/833] fix getentity on comm/card.php --- htdocs/comm/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index fcd3823b0c2..969d7142139 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -836,7 +836,7 @@ if ($object->id > 0) $sql .= ', s.rowid as socid'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql .= " AND e.entity IN (".getEntity('expedition').")"; + $sql .= " AND e.entity IN (".getEntity('commande').")"; $sql .= ' GROUP BY e.rowid'; $sql .= ', e.ref'; $sql .= ', e.date_creation'; From 59e4b3d634a46d1716ae5c611b5c4e6ef34f2f8a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 12 Mar 2020 04:56:36 +0100 Subject: [PATCH 014/833] FIX: Accounting management of intra-community sales to a non-taxable thirdparty Related to this discussion : https://www.dolibarr.fr/forum/t/gestion-des-comptes-de-vente-intracommunautaire-et-vente-ce-non-exemptee-de-tva/32285 --- htdocs/accountancy/customer/list.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index d964d348889..c0e40abd8c8 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -439,7 +439,10 @@ if ($result) { $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { - if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + if ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale without VAT intra community number + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { // Foreign sale @@ -452,7 +455,10 @@ if ($result) { $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { - if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + if ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale without VAT intra community number + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { @@ -470,7 +476,11 @@ if ($result) { $objp->aarowid_suggest = $objp->aarowid; $suggestedaccountingaccountfor = ''; } else { - if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + if ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale without VAT intra community number + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale $objp->code_sell_p = $objp->code_sell_intra; $objp->aarowid_suggest = $objp->aarowid_intra; $suggestedaccountingaccountfor = 'eec'; From 29b2ea77d5ce18133bd8fba48e451883521df29b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 12 Mar 2020 09:44:43 +0100 Subject: [PATCH 015/833] NEW : special option MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION to store in document line created form other document s lines the id of origin lines and origin class line rather than origin object id and origin object type --- htdocs/comm/propal/class/propal.class.php | 16 ++++++++++++---- htdocs/commande/class/commande.class.php | 16 ++++++++++++---- htdocs/compta/facture/class/facture.class.php | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3fa163594a2..b59dbc3887b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -440,8 +440,8 @@ class Propal extends CommonObject * @param int $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $origin 'order', ... - * @param int $origin_id Id of origin object + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param double $pu_ht_devise Unit price in currency * @param int $fk_remise_except Id discount if line is from a discount * @return int >0 if OK, <0 if KO @@ -1099,6 +1099,14 @@ class Propal extends CommonObject $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) { + $originid=$line->origin_id; + $origintype=$line->origin; + } else { + $originid=$line->id; + $origintype=$this->element; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -1122,8 +1130,8 @@ class Propal extends CommonObject $line->date_end, $line->array_options, $line->fk_unit, - $this->element, - $line->id + $origintype, + $originid ); if ($result < 0) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7249973f768..cc0040622f9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -927,6 +927,14 @@ class Commande extends CommonOrder $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) { + $originid=$line->origin_id; + $origintype=$line->origin; + } else { + $originid=$line->id; + $origintype=$this->element; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -951,8 +959,8 @@ class Commande extends CommonOrder $line->label, $line->array_options, $line->fk_unit, - $line->origin, - $line->origin_id + $origintype, + $originid ); if ($result < 0) { @@ -1355,8 +1363,8 @@ class Commande extends CommonOrder * @param string $label Label * @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $origin 'order', ... - * @param int $origin_id Id of origin object + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param double $pu_ht_devise Unit price in currency * @return int >0 if OK, <0 if KO * diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0549d70b10a..6ea22d77891 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -807,6 +807,14 @@ class Facture extends CommonInvoice $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) { + $originid=$line->origin_id; + $origintype=$line->origin; + } else { + $originid=$line->id; + $origintype=$this->element; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -826,8 +834,8 @@ class Facture extends CommonInvoice $line->product_type, $line->rang, $line->special_code, - $this->element, - $line->id, + $origintype, + $originid, $fk_parent_line, $line->fk_fournprice, $line->pa_ht, @@ -2936,8 +2944,8 @@ class Facture extends CommonInvoice * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. * @param int $rang Position of line * @param int $special_code Special code (also used by externals modules!) - * @param string $origin 'order', ... - * @param int $origin_id Id of origin object + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param int $fk_parent_line Id of parent line * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' From 2ae7cfeffacccdec7956eb83786db13b610131e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2020 10:56:25 +0100 Subject: [PATCH 016/833] Fix fields --- htdocs/ticket/class/ticket.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index e030782cc94..41ba9508ccb 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -193,12 +193,12 @@ class Ticket extends CommonObject 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"), 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), - 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), + 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>501, 'notnull'=>1), 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1), 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), - 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>""), + 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>1), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), From e7056a9ade7e88414bc688e7d21893306dac7f26 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 12 Mar 2020 11:00:17 +0100 Subject: [PATCH 017/833] NEW add a parameter to group same product --- htdocs/langs/en_US/cashdesk.lang | 1 + htdocs/langs/fr_FR/cashdesk.lang | 1 + htdocs/takepos/admin/setup.php | 7 +++++++ htdocs/takepos/invoice.php | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index d4355566872..ef939b31258 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -92,3 +92,4 @@ PrintMethod=Print method ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. ByTerminal=By terminal TakeposNumpadUsePaymentIcon=Use payment icon on numpad +TakeposGroupSameProduct=Group same products lines diff --git a/htdocs/langs/fr_FR/cashdesk.lang b/htdocs/langs/fr_FR/cashdesk.lang index 03ca0155daa..dc4e47cb868 100644 --- a/htdocs/langs/fr_FR/cashdesk.lang +++ b/htdocs/langs/fr_FR/cashdesk.lang @@ -83,3 +83,4 @@ ProductSupplements=Suppléments de produit SupplementCategory=Catégorie des suppléments SortProductField=Champ pour le tri des produits TakeposNumpadUsePaymentIcon=Utilisation d'icônes sur les touches des modes de règlement du pavé numérique +TakeposGroupSameProduct=Regrouper les mêmes lignes de produits diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index fce4d6d324f..830ca9154f2 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -76,6 +76,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SORTPRODUCTFIELD", GETPOST('TAKEPOS_SORTPRODUCTFIELD', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TAKEPOS_GROUP_SAME_PRODUCT', GETPOST('TAKEPOS_GROUP_SAME_PRODUCT', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); @@ -179,6 +180,12 @@ $array = array('rowid' => 'ID', 'ref' => 'Ref', 'label' => 'Label', 'datec' => ' print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD) ? 'rowid' : $conf->global->TAKEPOS_SORTPRODUCTFIELD), 0, 0, 0, '', 1); print "
'; +print $langs->trans('TakeposGroupSameProduct'); +print ''; +print ajax_constantonoff("TAKEPOS_GROUP_SAME_PRODUCT", array(), $conf->entity, 0, 0, 1, 0); +print "
'.$langs->trans($reg[1]).'
' . $label . ''.$label.''; // Do not force class=right, or it align also the content of the select box + print ''; // Do not force class=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
'; print ''; - print ''; + print ''; print "\n"; - print ''; + print ''; print '\n"; if ($mysoc->isInEEC()) { - print ''; + print ''; print '\n"; } - print ''; + print ''; print '\n"; - print ''; + print ''; print '\n"; if ($mysoc->isInEEC()) { - print ''; - print '\n"; + print ''; + print '\n"; } - print ''; + print ''; print '\n"; print "
' . $langs->trans('Options') . '' . $langs->trans('Description') . ''.$langs->trans('Options').''.$langs->trans('Description').'
' . $langs->trans('OptionModeProductSell') . '
'.$langs->trans('OptionModeProductSell').''.$langs->trans('OptionModeProductSellDesc'); print "
' . $langs->trans('OptionModeProductSellIntra') . '
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); print "
' . $langs->trans('OptionModeProductSellExport') . '
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); print "
' . $langs->trans('OptionModeProductBuy') . '
'.$langs->trans('OptionModeProductBuy').''.$langs->trans('OptionModeProductBuyDesc')."
' . $langs->trans('OptionModeProductBuyIntra') . '' . $langs->trans('OptionModeProductBuyDesc') . "
'.$langs->trans('OptionModeProductBuyIntra').''.$langs->trans('OptionModeProductBuyDesc')."
' . $langs->trans('OptionModeProductBuyExport') . '
'.$langs->trans('OptionModeProductBuyExport').''.$langs->trans('OptionModeProductBuyDesc')."
\n"; - print '
'; + print '
'; print "
\n"; // Filter on categories - $moreforfilter=''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $moreforfilter = ''; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $buttonsave = ''; + $buttonsave = ''; //print '
'.$buttonsave.'
'; - $texte=$langs->trans("ListOfProductsServices"); + $texte = $langs->trans("ListOfProductsServices"); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit); print '
'; - print ''; + print '
'; print ''; - print ''; - print ''; - if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ''; + print ''; + print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ''; // On sell if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print ''; @@ -431,13 +431,13 @@ if ($result) } // Current account print ''; print ''; print ''; print ''; @@ -445,36 +445,36 @@ if ($result) print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); // On sell / On purchase if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_sell"; + $fieldtosortaccount = "p.accountancy_code_sell"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_sell_intra"; + $fieldtosortaccount = "p.accountancy_code_sell_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_sell_export"; + $fieldtosortaccount = "p.accountancy_code_sell_export"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_buy"; + $fieldtosortaccount = "p.accountancy_code_buy"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_buy_intra"; + $fieldtosortaccount = "p.accountancy_code_buy_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount="p.accountancy_code_buy_export"; + $fieldtosortaccount = "p.accountancy_code_buy_export"; } print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); - $clickpitco=$form->showCheckAddButtons('checkforselect', 1); + $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); print ''; $product_static = new Product($db); - $i=0; + $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); @@ -491,37 +491,37 @@ if ($result) // Sales if ($obj->product_type == 0) { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_export; } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_export; } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } } @@ -529,37 +529,37 @@ if ($result) // Purchases if ($obj->product_type == 0) { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_export; } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_export; } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } } @@ -611,72 +611,72 @@ if ($result) print ''; // New account to set - $defaultvalue=''; + $defaultvalue = ''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { // Accounting account buy print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { // Accounting account buy intra (In EEC) print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { // Accounting account buy export (Out of EEC) print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { // Accounting account sell print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { // Accounting account sell intra (In EEC) print ''; } else { // Accounting account sell export (Out of EEC) print ''; } // Checkbox select print ''; + print ''; print ""; - $i ++; + $i++; } print '
'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).''; - print ''; - $listofvals=array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount")); + print ''; + $listofvals = array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount")); print ' '.$langs->trans("or").' '.$form->selectarray('search_current_account_valid', $listofvals, $search_current_account_valid, 1); print ' '; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy; - $codesell=length_accountg($obj->accountancy_code_buy); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; + $codesell = length_accountg($obj->accountancy_code_buy); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_intra; - $codesell=length_accountg($obj->accountancy_code_buy_intra); + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_intra; + $codesell = length_accountg($obj->accountancy_code_buy_intra); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_export; - $codesell=length_accountg($obj->accountancy_code_buy_export); + if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_export; + $codesell = length_accountg($obj->accountancy_code_buy_export); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodsell; - $codesell=length_accountg($obj->accountancy_code_sell); + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodsell; - $codesell=length_accountg($obj->accountancy_code_sell_intra); + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_intra); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue=$compta_prodsell; - $codesell=length_accountg($obj->accountancy_code_sell_export); - if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_export); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; - print '
'; print '
'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 9b6ad2fbbb0..4b0337c7848 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -204,7 +204,7 @@ if (empty($reshook)) $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; - $search_not_reconciled=''; + $search_not_reconciled = ''; } // Must be after the remove filter action, before the export. @@ -276,32 +276,32 @@ if (empty($reshook)) if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; $tmp = dol_getdate($search_date_creation_start); - $param .= '&date_creation_startmonth=' . urlencode($tmp['mon']) . '&date_creation_startday=' . urlencode($tmp['mday']) . '&date_creation_startyear=' . urlencode($tmp['year']); + $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); } if (!empty($search_date_creation_end)) { $filter['t.date_creation<='] = $search_date_creation_end; $tmp = dol_getdate($search_date_creation_end); - $param .= '&date_creation_endmonth=' .urlencode($tmp['mon']) . '&date_creation_endday=' . urlencode($tmp['mday']) . '&date_creation_endyear=' . urlencode($tmp['year']); + $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); } if (!empty($search_date_modification_start)) { $filter['t.tms>='] = $search_date_modification_start; $tmp = dol_getdate($search_date_modification_start); - $param .= '&date_modification_startmonth=' . urlencode($tmp['mon']) . '&date_modification_startday=' . urlencode($tmp['mday']) . '&date_modification_startyear=' . urlencode($tmp['year']); + $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); } if (!empty($search_date_modification_end)) { $filter['t.tms<='] = $search_date_modification_end; $tmp = dol_getdate($search_date_modification_end); - $param .= '&date_modification_endmonth=' . urlencode($tmp['mon']) . '&date_modification_endday=' . urlencode($tmp['mday']) . '&date_modification_endyear=' . urlencode($tmp['year']); + $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); } if (!empty($search_date_export_start)) { $filter['t.date_export>='] = $search_date_export_start; $tmp = dol_getdate($search_date_export_start); - $param .= '&date_export_startmonth=' . urlencode($tmp['mon']) . '&date_export_startday=' . urlencode($tmp['mday']) . '&date_export_startyear=' . urlencode($tmp['year']); + $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); } if (!empty($search_date_export_end)) { $filter['t.date_export<='] = $search_date_export_end; $tmp = dol_getdate($search_date_export_end); - $param .= '&date_export_endmonth=' . urlencode($tmp['mon']) . '&date_export_endday=' . urlencode($tmp['mday']) . '&date_export_endyear=' . urlencode($tmp['year']); + $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; @@ -315,9 +315,9 @@ if (empty($reshook)) $filter['t.lettering_code'] = $search_lettering_code; $param .= '&search_lettering_code='.urlencode($search_lettering_code); } - if (! empty($search_not_reconciled)) { + if (!empty($search_not_reconciled)) { $filter['t.reconciled_option'] = $search_not_reconciled; - $param .= '&search_not_reconciled=' . urlencode($search_not_reconciled); + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } } @@ -768,7 +768,7 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { print ''; print ''; - print '
'.$langs->trans("NotReconciled").''; + print '
'.$langs->trans("NotReconciled").''; print ''; } // Code journal @@ -953,9 +953,9 @@ while ($i < min($num, $limit)) $objectstatic->fetch($line->fk_doc); //$modulepart = 'expensereport'; - $filename=dol_sanitizeFileName($line->doc_ref); - $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); } else @@ -969,7 +969,7 @@ while ($i < min($num, $limit)) // Picto + Ref print ''; - if($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $documentlink; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 2c8ad2432a3..bcc042d8c71 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -480,7 +480,7 @@ if ($result) { } } - if (! empty($objp->code_buy_p)) { + if (!empty($objp->code_buy_p)) { // Value was defined previously } else { $code_buy_p_notset = 'color:orange'; @@ -561,7 +561,7 @@ if ($result) { // Suggested accounting account print ''; $suggestedid = $objp->aarowid_suggest; - if (empty($suggestedid) && empty($objp->code_buy_p) && ! empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) + if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l])) { @@ -597,7 +597,7 @@ if ($result) { print $db->error(); } if ($db->type == 'mysqli') { - $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation + $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation } // Add code to auto check the box when we select an account diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a14cdec8fff..fa8ae9fc2f3 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -32,9 +32,9 @@ * \ingroup member * \brief File of class to manage members of a foundation */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** @@ -341,7 +341,7 @@ class Adherent extends CommonObject if (dol_textishtml($text, 0)) $msgishtml = 1; } - dol_syslog('send_an_email msgishtml=' . $msgishtml); + dol_syslog('send_an_email msgishtml='.$msgishtml); $texttosend = $this->makeSubstitution($text); $subjecttosend = $this->makeSubstitution($subject); @@ -351,15 +351,15 @@ class Adherent extends CommonObject $from = $conf->email_from; if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM; - $trackid = 'mem' . $this->id; + $trackid = 'mem'.$this->id; // Send email (substitutionarray must be done just before this) - include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, '', '', $trackid, $moreinheader); if ($mailfile->sendfile()) { return 1; } else { - $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email) . '. ' . $mailfile->error; + $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; return -1; } } @@ -381,26 +381,26 @@ class Adherent extends CommonObject if (dol_textishtml($text, 1)) $msgishtml = 1; $infos = ''; - if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle") . ": " . $this->getCivilityLabel() . "\n"; - $infos .= $langs->transnoentities("id") . ": " . $this->id . "\n"; - $infos .= $langs->transnoentities("Lastname") . ": " . $this->lastname . "\n"; - $infos .= $langs->transnoentities("Firstname") . ": " . $this->firstname . "\n"; - $infos .= $langs->transnoentities("Company") . ": " . $this->company . "\n"; - $infos .= $langs->transnoentities("Address") . ": " . $this->address . "\n"; - $infos .= $langs->transnoentities("Zip") . ": " . $this->zip . "\n"; - $infos .= $langs->transnoentities("Town") . ": " . $this->town . "\n"; - $infos .= $langs->transnoentities("Country") . ": " . $this->country . "\n"; - $infos .= $langs->transnoentities("EMail") . ": " . $this->email . "\n"; - $infos .= $langs->transnoentities("PhonePro") . ": " . $this->phone . "\n"; - $infos .= $langs->transnoentities("PhonePerso") . ": " . $this->phone_perso . "\n"; - $infos .= $langs->transnoentities("PhoneMobile") . ": " . $this->phone_mobile . "\n"; + if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; + $infos .= $langs->transnoentities("id").": ".$this->id."\n"; + $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; + $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; + $infos .= $langs->transnoentities("Company").": ".$this->company."\n"; + $infos .= $langs->transnoentities("Address").": ".$this->address."\n"; + $infos .= $langs->transnoentities("Zip").": ".$this->zip."\n"; + $infos .= $langs->transnoentities("Town").": ".$this->town."\n"; + $infos .= $langs->transnoentities("Country").": ".$this->country."\n"; + $infos .= $langs->transnoentities("EMail").": ".$this->email."\n"; + $infos .= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; + $infos .= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; + $infos .= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $infos .= $langs->transnoentities("Login") . ": " . $this->login . "\n"; - $infos .= $langs->transnoentities("Password") . ": " . $this->pass . "\n"; + $infos .= $langs->transnoentities("Login").": ".$this->login."\n"; + $infos .= $langs->transnoentities("Password").": ".$this->pass."\n"; } - $infos .= $langs->transnoentities("Birthday") . ": " . $birthday . "\n"; - $infos .= $langs->transnoentities("Photo") . ": " . $this->photo . "\n"; - $infos .= $langs->transnoentities("Public") . ": " . yn($this->public); + $infos .= $langs->transnoentities("Birthday").": ".$birthday."\n"; + $infos .= $langs->transnoentities("Photo").": ".$this->photo."\n"; + $infos .= $langs->transnoentities("Public").": ".yn($this->public); // Substitutions $substitutionarray = array('__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), @@ -481,22 +481,22 @@ class Adherent extends CommonObject $this->db->begin(); // Insert member - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "adherent"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; $sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; $sql .= " VALUES ("; - $sql .= " '" . $this->db->idate($this->datec) . "'"; - $sql .= ", " . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null"); - $sql .= ", " . ($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script - $sql .= ", null, null, '" . $this->db->escape($this->morphy) . "'"; - $sql .= ", " . $this->typeid; - $sql .= ", " . $conf->entity; - $sql .= ", " . (!empty($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null"); + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); + $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script + $sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; + $sql .= ", ".$this->typeid; + $sql .= ", ".$conf->entity; + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ")"; - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "adherent"); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); if ($id > 0) { $this->id = $id; $this->ref = (string) $id; @@ -511,10 +511,10 @@ class Adherent extends CommonObject // Add link to user if ($this->user_id) { // Add link to user - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET"; - $sql .= " fk_member = " . $this->id; - $sql .= " WHERE rowid = " . $this->user_id; - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; + $sql .= " fk_member = ".$this->id; + $sql .= " WHERE rowid = ".$this->user_id; + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = 'Failed to update user to make link with member'; @@ -533,7 +533,7 @@ class Adherent extends CommonObject } if (count($this->errors)) { - dol_syslog(get_class($this) . "::create " . implode(',', $this->errors), LOG_ERR); + dol_syslog(get_class($this)."::create ".implode(',', $this->errors), LOG_ERR); $this->db->rollback(); return -3; } else { @@ -542,7 +542,7 @@ class Adherent extends CommonObject } } else { $this->error = 'Failed to get last insert id'; - dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } @@ -572,7 +572,7 @@ class Adherent extends CommonObject $nbrowsaffected = 0; $error = 0; - dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncuser=" . $nosyncuser . ", nosyncuserpass=" . $nosyncuserpass . " nosyncthirdparty=" . $nosyncthirdparty . ", email=" . + dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=". $this->email); // Clean parameters @@ -598,43 +598,43 @@ class Adherent extends CommonObject $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; - $sql .= " civility = " . ($this->civility_id ? "'" . $this->db->escape($this->civility_id) . "'" : "null"); - $sql .= ", firstname = " . ($this->firstname ? "'" . $this->db->escape($this->firstname) . "'" : "null"); - $sql .= ", lastname = " . ($this->lastname ? "'" . $this->db->escape($this->lastname) . "'" : "null"); - $sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null"); // 'man' or 'woman' - $sql .= ", login = " . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null"); - $sql .= ", societe = " . ($this->company ? "'" . $this->db->escape($this->company) . "'" : ($this->societe ? "'" . $this->db->escape($this->societe) . "'" : "null")); - $sql .= ", fk_soc = " . ($this->socid > 0 ? $this->db->escape($this->socid) : "null"); - $sql .= ", address = " . ($this->address ? "'" . $this->db->escape($this->address) . "'" : "null"); - $sql .= ", zip = " . ($this->zip ? "'" . $this->db->escape($this->zip) . "'" : "null"); - $sql .= ", town = " . ($this->town ? "'" . $this->db->escape($this->town) . "'" : "null"); - $sql .= ", country = " . ($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); - $sql .= ", state_id = " . ($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); - $sql .= ", email = '" . $this->db->escape($this->email) . "'"; - $sql .= ", socialnetworks = '" . $this->db->escape(json_encode($this->socialnetworks)) . "'"; - $sql .= ", phone = " . ($this->phone ? "'" . $this->db->escape($this->phone) . "'" : "null"); - $sql .= ", phone_perso = " . ($this->phone_perso ? "'" . $this->db->escape($this->phone_perso) . "'" : "null"); - $sql .= ", phone_mobile = " . ($this->phone_mobile ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null"); - $sql .= ", note_private = " . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null"); - $sql .= ", note_public = " . ($this->note_public ? "'" . $this->db->escape($this->note_public) . "'" : "null"); - $sql .= ", photo = " . ($this->photo ? "'" . $this->db->escape($this->photo) . "'" : "null"); - $sql .= ", public = '" . $this->db->escape($this->public) . "'"; - $sql .= ", statut = " . $this->db->escape($this->statut); - $sql .= ", fk_adherent_type = " . $this->db->escape($this->typeid); - $sql .= ", morphy = '" . $this->db->escape($this->morphy) . "'"; - $sql .= ", birth = " . ($this->birth ? "'" . $this->db->idate($this->birth) . "'" : "null"); - if ($this->socid) $sql .= ", fk_soc = '" . $this->db->escape($this->socid) . "'"; // Must be modified only when creating from a third-party - if ($this->datefin) $sql .= ", datefin = '" . $this->db->idate($this->datefin) . "'"; // Must be modified only when deleting a subscription - if ($this->datevalid) $sql .= ", datevalid = '" . $this->db->idate($this->datevalid) . "'"; // Must be modified only when validating a member - $sql .= ", fk_user_mod = " . ($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; + $sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null"); + $sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null"); + $sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null"); + $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' + $sql .= ", login = ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); + $sql .= ", societe = ".($this->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null")); + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); + $sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null"); + $sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null"); + $sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null"); + $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); + $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); + $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); + $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); + $sql .= ", phone_mobile = ".($this->phone_mobile ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); + $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); + $sql .= ", public = '".$this->db->escape($this->public)."'"; + $sql .= ", statut = ".$this->db->escape($this->statut); + $sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid); + $sql .= ", morphy = '".$this->db->escape($this->morphy)."'"; + $sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null"); + if ($this->socid) $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party + if ($this->datefin) $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription + if ($this->datevalid) $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member + $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest + $sql .= " WHERE rowid = ".$this->id; // If we change the type of membership, we set also label of new type if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; - $sql2 .= " FROM " . MAIN_DB_PREFIX . "adherent_type"; - $sql2 .= " WHERE rowid = " . $this->typeid; + $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2 .= " WHERE rowid = ".$this->typeid; $resql2 = $this->db->query($sql2); if ($resql2) { while ($obj = $this->db->fetch_object($resql2)) { @@ -643,7 +643,7 @@ class Adherent extends CommonObject } } - dol_syslog(get_class($this) . "::update update member", LOG_DEBUG); + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { unset($this->country_code); @@ -666,7 +666,7 @@ class Adherent extends CommonObject // Update password if (!$error && $this->pass) { - dol_syslog(get_class($this) . "::update update password"); + dol_syslog(get_class($this)."::update update password"); if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1; @@ -678,9 +678,9 @@ class Adherent extends CommonObject // Remove links to user and replace with new one if (!$error) { - dol_syslog(get_class($this) . "::update update link to user"); - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update update link to user"); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -689,8 +689,8 @@ class Adherent extends CommonObject } // If there is a user linked to this member if ($this->user_id > 0) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id . " WHERE rowid = " . $this->user_id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." WHERE rowid = ".$this->user_id; + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -704,9 +704,9 @@ class Adherent extends CommonObject { // Update information on linked user if it is an update if (!$error && $this->user_id > 0 && !$nosyncuser) { - require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - dol_syslog(get_class($this) . "::update update linked user"); + dol_syslog(get_class($this)."::update update linked user"); $luser = new User($this->db); $result = $luser->fetch($this->user_id); @@ -743,7 +743,7 @@ class Adherent extends CommonObject $result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates if ($result < 0) { $this->error = $luser->error; - dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } else { @@ -754,9 +754,9 @@ class Adherent extends CommonObject // Update information on linked thirdparty if it is an update if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - dol_syslog(get_class($this) . "::update update linked thirdparty"); + dol_syslog(get_class($this)."::update update linked thirdparty"); // This member is linked with a thirdparty, so we also update thirdparty informations // if this is an update. @@ -779,7 +779,7 @@ class Adherent extends CommonObject if ($result < 0) { $this->error = $lthirdparty->error; $this->errors = $lthirdparty->errors; - dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } elseif ($result < 0) { @@ -828,11 +828,11 @@ class Adherent extends CommonObject // Search for last subscription id and end date $sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin"; - $sql .= " FROM " . MAIN_DB_PREFIX . "subscription"; - $sql .= " WHERE fk_adherent=" . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE fk_adherent=".$this->id; $sql .= " ORDER by dateadh DESC"; // Sort by start subscription date - dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG); + dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -840,11 +840,11 @@ class Adherent extends CommonObject $datedeb = $this->db->jdate($obj->datedeb); $datefin = $this->db->jdate($obj->datefin); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; - $sql .= " datefin=" . ($datefin != '' ? "'" . $this->db->idate($datefin) . "'" : "null"); - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; + $sql .= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG); + dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->last_subscription_date = $dateop; @@ -893,8 +893,8 @@ class Adherent extends CommonObject } // Remove category - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_member WHERE fk_member = " . $rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -904,8 +904,8 @@ class Adherent extends CommonObject // Remove subscription if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "subscription WHERE fk_adherent = " . $rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -932,15 +932,15 @@ class Adherent extends CommonObject if ($result < 0) { $error++; $errorflag = -4; - dol_syslog(get_class($this) . "::delete erreur " . $errorflag . " " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); } } } // Remove adherent if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "adherent WHERE rowid = " . $rowid; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -975,11 +975,11 @@ class Adherent extends CommonObject $error = 0; - dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " isencrypted=" . $isencrypted); + dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); // If new password not provided, we generate one if (!$password) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $password = getRandomPassword(false); } @@ -994,18 +994,18 @@ class Adherent extends CommonObject $this->db->begin(); // Mise a jour - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent"; - $sql .= " SET pass_crypted = '" . $this->db->escape($password_crypted) . "'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; //if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) if ($isencrypted) { $sql .= ", pass = null"; } else { - $sql .= ", pass = '" . $this->db->escape($password_indatabase) . "'"; + $sql .= ", pass = '".$this->db->escape($password_indatabase)."'"; } - $sql .= " WHERE rowid = " . $this->id; + $sql .= " WHERE rowid = ".$this->id; //dol_syslog("Adherent::Password sql=hidden"); - dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG); + dol_syslog(get_class($this)."::setPassword", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $nbaffectedrows = $this->db->affected_rows($result); @@ -1016,7 +1016,7 @@ class Adherent extends CommonObject $this->pass_indatabase_crypted = $password_crypted; if ($this->user_id && !$nosyncuser) { - require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // This member is linked with a user, so we also update users informations // if this is an update. @@ -1027,7 +1027,7 @@ class Adherent extends CommonObject $result = $luser->setPassword($user, $this->pass, 0, 0, 1); if ($result < 0) { $this->error = $luser->error; - dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; } } else { @@ -1074,8 +1074,8 @@ class Adherent extends CommonObject $this->db->begin(); // If user is linked to this member, remove old link to this member - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id; - dol_syslog(get_class($this) . "::setUserId", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; + dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -1085,9 +1085,9 @@ class Adherent extends CommonObject // Set link to user if ($userid > 0) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id; - $sql .= " WHERE rowid = " . $userid; - dol_syslog(get_class($this) . "::setUserId", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id; + $sql .= " WHERE rowid = ".$userid; + dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); @@ -1116,18 +1116,18 @@ class Adherent extends CommonObject // Remove link to third party onto any other members if ($thirdpartyid > 0) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = null"; - $sql .= " WHERE fk_soc = '" . $thirdpartyid . "'"; - $sql .= " AND entity = " . $conf->entity; - dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null"; + $sql .= " WHERE fk_soc = '".$thirdpartyid."'"; + $sql .= " AND entity = ".$conf->entity; + dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); } // Add link to third party for current member - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = " . ($thirdpartyid > 0 ? $thirdpartyid : 'null'); - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG); + dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -1152,9 +1152,9 @@ class Adherent extends CommonObject // phpcs:enable global $conf; - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; - $sql .= " WHERE login='" . $this->db->escape($login) . "'"; - $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql .= " WHERE login='".$this->db->escape($login)."'"; + $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -1180,10 +1180,10 @@ class Adherent extends CommonObject // phpcs:enable global $conf; - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; - $sql .= " WHERE firstname='" . $this->db->escape($firstname) . "'"; - $sql .= " AND lastname='" . $this->db->escape($lastname) . "'"; - $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql .= " WHERE firstname='".$this->db->escape($firstname)."'"; + $sql .= " AND lastname='".$this->db->escape($lastname)."'"; + $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -1227,24 +1227,24 @@ class Adherent extends CommonObject $sql .= " dep.nom as state, dep.code_departement as state_code,"; $sql .= " t.libelle as type, t.subscription as subscription,"; $sql .= " u.rowid as user_id, u.login as user_login"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t, " . MAIN_DB_PREFIX . "adherent as d"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON d.country = c.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as dep ON d.state_id = dep.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u ON d.rowid = u.fk_member"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; if ($rowid) - $sql .= " AND d.rowid=" . $rowid; + $sql .= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { - $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; if ($ref) - $sql .= " AND d.rowid='" . $this->db->escape($ref) . "'"; + $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; elseif ($fk_soc > 0) - $sql .= " AND d.fk_soc=" . $fk_soc; + $sql .= " AND d.fk_soc=".$fk_soc; } elseif ($ref_ext) { - $sql .= " AND d.ref_ext='" . $this->db->escape($ref_ext) . "'"; + $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -1257,7 +1257,7 @@ class Adherent extends CommonObject $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code ? ($langs->trans("Civility" . $obj->civility_code) != ("Civility" . $obj->civility_code) ? $langs->trans("Civility" . $obj->civility_code) : $obj->civility_code) : ''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; @@ -1281,8 +1281,8 @@ class Adherent extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_code; - if ($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) - $this->country = $langs->transnoentitiesnoconv("Country" . $obj->country_code); + if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) + $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code); else $this->country = $obj->country; @@ -1354,17 +1354,17 @@ class Adherent extends CommonObject // phpcs:enable global $langs; - require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,"; $sql .= " c.tms as datem,"; $sql .= " c.datec as datec,"; $sql .= " c.dateadh as dateh,"; $sql .= " c.datef as datef"; - $sql .= " FROM " . MAIN_DB_PREFIX . "subscription as c"; - $sql .= " WHERE c.fk_adherent = " . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " WHERE c.fk_adherent = ".$this->id; $sql .= " ORDER BY c.dateadh"; - dol_syslog(get_class($this) . "::fetch_subscriptions", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_subscriptions", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1401,7 +1401,7 @@ class Adherent extends CommonObject } return 1; } else { - $this->error = $this->db->error() . ' sql=' . $sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -1425,7 +1425,7 @@ class Adherent extends CommonObject { global $conf, $langs, $user; - require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $error = 0; @@ -1505,12 +1505,12 @@ class Adherent extends CommonObject $this->invoice = null; // This will contains invoice if an invoice is created - dol_syslog("subscriptionComplementaryActions subscriptionid=" . $subscriptionid . " option=" . $option . " accountid=" . $accountid . " datesubscription=" . $datesubscription . " paymentdate=" . - $paymentdate . " label=" . $label . " amount=" . $amount . " num_chq=" . $num_chq . " autocreatethirdparty=" . $autocreatethirdparty); + dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=". + $paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty); // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' if ($option == 'bankdirect' && $accountid) { - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acct = new Account($this->db); $result = $acct->fetch($accountid); @@ -1519,11 +1519,11 @@ class Adherent extends CommonObject $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { - $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT . '/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); + $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); if ($inserturlid > 0) { // Update table subscription - $sql = "UPDATE " . MAIN_DB_PREFIX . "subscription SET fk_bank=" . $insertid; - $sql .= " WHERE rowid=" . $subscriptionid; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; + $sql .= " WHERE rowid=".$subscriptionid; dol_syslog("subscription::subscription", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1546,8 +1546,8 @@ class Adherent extends CommonObject // If option choosed, we create invoice if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') { - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/paymentterm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; $invoice = new Facture($this->db); $customer = new Societe($this->db); @@ -1659,9 +1659,9 @@ class Adherent extends CommonObject // Add payment onto invoice if (!$error && $option == 'bankviainvoice' && $accountid) { - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; $amounts = array(); $amounts[$invoice->id] = price2num($amount); @@ -1695,8 +1695,8 @@ class Adherent extends CommonObject if (!$error && !empty($bank_line_id)) { // Update fk_bank into subscription table - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'subscription SET fk_bank=' . $bank_line_id; - $sql .= ' WHERE rowid=' . $subscriptionid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; + $sql .= ' WHERE rowid='.$subscriptionid; $result = $this->db->query($sql); if (!$result) { @@ -1751,19 +1751,19 @@ class Adherent extends CommonObject // Check parameters if ($this->statut == 1) { - dol_syslog(get_class($this) . "::validate statut of member does not allow this", LOG_WARNING); + dol_syslog(get_class($this)."::validate statut of member does not allow this", LOG_WARNING); return 0; } $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql .= " statut = 1"; - $sql .= ", datevalid = '" . $this->db->idate($now) . "'"; - $sql .= ", fk_user_valid=" . $user->id; - $sql .= " WHERE rowid = " . $this->id; + $sql .= ", datevalid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::validate", LOG_DEBUG); + dol_syslog(get_class($this)."::validate", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->statut = 1; @@ -1803,16 +1803,16 @@ class Adherent extends CommonObject // Check parameters if ($this->statut == 0) { - dol_syslog(get_class($this) . "::resiliate statut of member does not allow this", LOG_WARNING); + dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING); return 0; } $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql .= " statut = 0"; - $sql .= ", fk_user_valid=" . $user->id; - $sql .= " WHERE rowid = " . $this->id; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); if ($result) { @@ -1848,7 +1848,7 @@ class Adherent extends CommonObject // phpcs:enable global $conf, $langs; - include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $mailmanspip = new MailmanSpip($this->db); $err = 0; @@ -1898,7 +1898,7 @@ class Adherent extends CommonObject // phpcs:enable global $conf, $langs; - include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $mailmanspip = new MailmanSpip($this->db); $err = 0; @@ -1949,7 +1949,7 @@ class Adherent extends CommonObject $code = (empty($this->civility_id) ? '' : $this->civility_id); if (empty($code)) return ''; - return $langs->getLabelFromKey($this->db, "Civility" . $code, "c_civility", "code", "label", $code); + return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); } /** @@ -1982,15 +1982,15 @@ class Adherent extends CommonObject } $label .= '
'; - $label .= '' . $langs->trans("Member") . ''; - if (!empty($this->ref)) $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (!empty($this->firstname) || !empty($this->lastname)) $label .= '
' . $langs->trans('Name') . ': ' . $this->getFullName($langs); - if (!empty($this->company)) $label .= '
' . $langs->trans('Company') . ': ' . $this->company; + $label .= ''.$langs->trans("Member").''; + if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->firstname) || !empty($this->lastname)) $label .= '
'.$langs->trans('Name').': '.$this->getFullName($langs); + if (!empty($this->company)) $label .= '
'.$langs->trans('Company').': '.$this->company; $label .= '
'; - $url = DOL_URL_ROOT . '/adherents/card.php?rowid=' . $this->id; + $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id; if ($option == 'subscription') { - $url = DOL_URL_ROOT . '/adherents/subscription.php?rowid=' . $this->id; + $url = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id; } if ($option != 'nolink') { @@ -2000,19 +2000,19 @@ class Adherent extends CommonObject if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkstart .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label = $langs->trans("ShowUser"); - $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; - $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - $linkstart .= $linkclose . '>'; + $linkstart .= $linkclose.'>'; $linkend = ''; $result .= $linkstart; @@ -2022,19 +2022,19 @@ class Adherent extends CommonObject if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-right: 3px;"'; // Only picto if ($withpictoimg > 0) - $picto = '' . - img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . ''; + $picto = ''. + img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo else { - $picto = ''; - $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); + $picto = ''; + $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); $picto .= ''; } $result .= $picto; } if ($withpictoimg > -2 && $withpictoimg != 2) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; if ($mode == 'login') $result .= dol_trunc($this->login, $maxlen); elseif ($mode == 'ref') @@ -2126,9 +2126,9 @@ class Adherent extends CommonObject $this->nb = array(); $sql = "SELECT count(a.rowid) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " WHERE a.statut > 0"; - $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; $resql = $this->db->query($sql); if ($resql) { @@ -2162,16 +2162,16 @@ class Adherent extends CommonObject $now = dol_now(); $sql = "SELECT a.rowid, a.datefin, a.statut"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a"; - $sql .= ", " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.fk_adherent_type = t.rowid"; if ($mode == 'expired') { $sql .= " AND a.statut = 1"; - $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND ((a.datefin IS NULL or a.datefin < '" . $this->db->idate($now) . "') AND t.subscription = 1)"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; + $sql .= " AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND t.subscription = 1)"; } elseif ($mode == 'shift') { $sql .= " AND a.statut = -1"; - $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND a.entity IN (".getEntity('adherent').")"; } $resql = $this->db->query($sql); @@ -2187,10 +2187,10 @@ class Adherent extends CommonObject $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24; $label = $langs->trans("MembersWithSubscriptionToReceive"); $labelShort = $langs->trans("MembersWithSubscriptionToReceiveShort"); - $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; + $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; } elseif ($mode == 'shift') { $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24; - $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=-1'; + $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=-1'; $label = $langs->trans("MembersListToValid"); $labelShort = $langs->trans("ToValidate"); } @@ -2331,9 +2331,9 @@ class Adherent extends CommonObject // phpcs:enable global $conf; $dn = ''; - if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS] . "," . $conf->global->LDAP_MEMBER_DN; + if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN; if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_DN; - if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS]; + if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS]; return $dn; } @@ -2413,7 +2413,7 @@ class Adherent extends CommonObject if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { // Create OpenLDAP MD5 password from Dolibarr MD5 password // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" - $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}' . base64_encode(hex2bin($this->pass_indatabase_crypted)); + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted)); } } } // Use $this->pass_indatabase value if exists @@ -2445,10 +2445,10 @@ class Adherent extends CommonObject $sql .= ' a.datevalid as datev,'; $sql .= ' a.tms as datem,'; $sql .= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'adherent as a'; - $sql .= ' WHERE a.rowid = ' . $id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'adherent as a'; + $sql .= ' WHERE a.rowid = '.$id; - dol_syslog(get_class($this) . "::info", LOG_DEBUG); + dol_syslog(get_class($this)."::info", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { @@ -2491,8 +2491,8 @@ class Adherent extends CommonObject public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles as mc"; - $sql .= " WHERE mc.email = '" . $this->db->escape($this->email) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.email = '".$this->db->escape($this->email)."'"; $sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes $resql = $this->db->query($sql); @@ -2526,7 +2526,7 @@ class Adherent extends CommonObject } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id'); @@ -2627,7 +2627,7 @@ class Adherent extends CommonObject $arraydaysbeforeend = explode(';', $daysbeforeendlist); foreach ($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { - dol_syslog(__METHOD__ . ' - Process delta = ' . $daysbeforeend, LOG_DEBUG); + dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG); if (!is_numeric($daysbeforeend)) { $blockingerrormsg = "Value for delta is not a positive or negative numeric"; @@ -2638,15 +2638,15 @@ class Adherent extends CommonObject $tmp = dol_getdate($now); $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'adherent'; - $sql .= " WHERE entity = " . $conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; - $sql .= " AND datefin = '" . $this->db->idate($datetosearchfor) . "'"; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; + $sql .= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; + $sql .= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; $resql = $this->db->query($sql); if ($resql) { $num_rows = $this->db->num_rows($resql); - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $adherent = new Adherent($this->db); $formmail = new FormMail($this->db); @@ -2670,7 +2670,7 @@ class Adherent extends CommonObject $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($languagecodeformember); $outputlangs->loadLangs(array("main", "members")); - dol_syslog("sendReminderForExpiredSubscription Language for member id " . $adherent->id . " set to " . $outputlangs->defaultlang . " mysoc->default_lang=" . $mysoc->default_lang); + dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang); $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; @@ -2687,10 +2687,10 @@ class Adherent extends CommonObject $from = $conf->global->ADHERENT_MAIL_FROM; $to = $adherent->email; - $trackid = 'mem' . $adherent->id; - $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription' . "\r\n"; + $trackid = 'mem'.$adherent->id; + $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; - include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); $result = $cmail->sendfile(); if (!$result) { @@ -2713,24 +2713,24 @@ class Adherent extends CommonObject $extraparams = ''; $actionmsg = ''; - $actionmsg2 = $langs->transnoentities('MailSentBy') . ' ' . CMailFile::getValidAddress($from, 4, 0, 1) . ' ' . $langs->transnoentities('To') . ' ' . + $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '. CMailFile::getValidAddress($sendto, 4, 0, 1); if ($message) { - $actionmsg = $langs->transnoentities('MailFrom') . ': ' . dol_escape_htmltag($from); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo') . ': ' . dol_escape_htmltag($sendto)); - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $message); } - require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; // Insert record of emails sent $actioncomm = new ActionComm($this->db); $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_' . $actioncode; + $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $actionmsg2; $actioncomm->note_private = $actionmsg; $actioncomm->fk_project = 0; @@ -2780,8 +2780,8 @@ class Adherent extends CommonObject $this->error = $blockingerrormsg; return 1; } else { - $this->output = 'Found ' . ($nbok + $nbko) . ' members to send reminder to.'; - $this->output .= ' Send email successfuly to ' . $nbok . ' members'; + $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.'; + $this->output .= ' Send email successfuly to '.$nbok.' members'; if (is_array($listofmembersok)) { $listofids = ''; $i = 0; @@ -2801,7 +2801,7 @@ class Adherent extends CommonObject $this->output .= $listofids; } if ($nbko) { - $this->output .= ' - Canceled for ' . $nbko . ' member (no email or email sending error)'; + $this->output .= ' - Canceled for '.$nbko.' member (no email or email sending error)'; if (is_array($listofmembersko)) { $listofids = ''; $i = 0; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 70ea29360c8..2f33b3ab49b 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -36,12 +36,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'projects', 'hrm', 'agenda')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminihm'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search -if (! defined("MAIN_MOTD")) define("MAIN_MOTD", ""); +if (!defined("MAIN_MOTD")) define("MAIN_MOTD", ""); @@ -49,13 +49,13 @@ if (! defined("MAIN_MOTD")) define("MAIN_MOTD", ""); * Action */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (GETPOST('cancel', 'alpha')) { - $action=''; + $action = ''; } // Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff) @@ -65,15 +65,15 @@ if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) { else dolibarr_del_const($db, $regs[2], $conf->entity); } -if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND)) +if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND; + $logofile = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND; dol_delete_file($logofile); dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND", $conf->entity); - $mysoc->logo=''; + $mysoc->logo = ''; /*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; dol_delete_file($logosmallfile); @@ -89,7 +89,7 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK if ($action == 'update') { dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); @@ -98,53 +98,53 @@ if ($action == 'update') if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); @@ -158,29 +158,29 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities + dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'none')), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'none')), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities + dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST('MAIN_BUGTRACK_ENABLELINK', 'aZ09'), 'chaine', 0, '', $conf->entity); - $varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/'; + $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; if ($_FILES[$varforimage]["tmp_name"]) { $reg = array(); if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { - $original_file=$reg[1]; + $original_file = $reg[1]; - $isimage=image_format_supported($original_file); + $isimage = image_format_supported($original_file); if ($isimage >= 0) { dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); - if (! is_dir($dirforimage)) + if (!is_dir($dirforimage)) { dol_mkdir($dirforimage); } - $result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); + $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); if ($result > 0) { dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity); @@ -189,7 +189,7 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $tmparray=explode(':', $result); + $tmparray = explode(':', $result); setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); } else @@ -209,7 +209,7 @@ if ($action == 'update') - $_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer + $_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -220,12 +220,12 @@ if ($action == 'update') * View */ -$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$form=new Form($db); -$formother=new FormOther($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formother = new FormOther($db); +$formadmin = new FormAdmin($db); print load_fiche_titre($langs->trans("GUISetup"), '', 'title_setup'); @@ -281,12 +281,12 @@ print ' '; print ''; // Max size of lists -print ''.$langs->trans("DefaultMaxSizeList").''; +print ''.$langs->trans("DefaultMaxSizeList").''; print ' '; print ''; // Max size of short lists on customer card -print ''.$langs->trans("DefaultMaxSizeShortList").''; +print ''.$langs->trans("DefaultMaxSizeShortList").''; print ' '; print ''; @@ -301,36 +301,36 @@ print ''; // First day for weeks print ''.$langs->trans("WeekStartOnDay").''; -print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'), 'MAIN_START_WEEK', 0); +print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); print ''; print ' '; print ''; // DefaultWorkingDays print ''.$langs->trans("DefaultWorkingDays").''; -print ''; +print ''; print ''; print ' '; print ''; // DefaultWorkingHours print ''.$langs->trans("DefaultWorkingHours").''; -print ''; +print ''; print ''; print ' '; print ''; // Firstname/Name print ''.$langs->trans("FirstnameNamePosition").''; -$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); -print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); +$array = array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); +print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); print ''; print ' '; print ''; // Hide unauthorized button print ''.$langs->trans("ButtonHideUnauthorized").''; -print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0, 1); +print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1); print ''; print ' '; print ''; @@ -353,28 +353,28 @@ print ' '; print ''; // Hide wiki link on login page -$pictohelp=''; +$pictohelp = ''; print ''.$langs->trans("DisableLinkToHelp", $pictohelp).''; -print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0, 1); +print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1); print ''; print ' '; print ''; // Message of the day on home page -$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount')); +$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount')); complete_substitutions_array($substitutionarray, $langs); print ''; -$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -foreach($substitutionarray as $key => $val) +$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; +foreach ($substitutionarray as $key => $val) { - $texthelp.=$key.'
'; + $texthelp .= $key.'
'; } print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); print ''; -$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); +$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD) ? $conf->global->MAIN_MOTD : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); print ''."\n"; @@ -391,23 +391,23 @@ print ' '; print ''; // Message on login page -$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user')); +$substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount', 'user')); complete_substitutions_array($substitutionarray, $langs); print ''; -$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -foreach($substitutionarray as $key => $val) +$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; +foreach ($substitutionarray as $key => $val) { - $texthelp.=$key.'
'; + $texthelp .= $key.'
'; } print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); print ''; -$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); +$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME) ? $conf->global->MAIN_HOME : ''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); print ''."\n"; // Hide helpcenter link on login page print ''.$langs->trans("DisableLinkToHelpCenter").''; -print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK', isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0, 1); +print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK', isset($conf->global->MAIN_HELPCENTER_DISABLELINK) ? $conf->global->MAIN_HELPCENTER_DISABLELINK : 0, 1); print ''; print ' '; print ''; @@ -416,13 +416,13 @@ print ''; print ''; print '
'; $disabled = ''; -if (! empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"'; +if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"'; print ''; if ($disabled) { print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') '; } -if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) { +if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { print ''.img_delete($langs->trans("Delete")).''; if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) { print '   '; diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9326082b193..87c91d0f621 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -119,16 +119,16 @@ class Proposals extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } $result = $this->propal->fetch($id, $ref, $ref_ext); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -162,18 +162,18 @@ class Proposals extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('propal').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -182,23 +182,23 @@ class Proposals extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -213,7 +213,7 @@ class Proposals extends DolibarrApi { $obj = $db->fetch_object($result); $proposal_static = new Propal($db); - if($proposal_static->fetch($obj->rowid)) { + if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($proposal_static); @@ -224,7 +224,7 @@ class Proposals extends DolibarrApi else { throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No proposal found'); } return $obj_ret; @@ -238,13 +238,13 @@ class Proposals extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->propal->$field = $value; } /*if (isset($request_data["lines"])) { @@ -272,16 +272,16 @@ class Proposals extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->propal->getLinesArray(); @@ -304,16 +304,16 @@ class Proposals extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -368,16 +368,16 @@ class Proposals extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if($result <= 0) { + if ($result <= 0) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -391,27 +391,27 @@ class Proposals extends DolibarrApi $updateRes = $this->propal->updateline( $lineid, - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, - isset($request_data->qty)?$request_data->qty:$propalline->qty, - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, - isset($request_data->desc)?$request_data->desc:$propalline->desc, + isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice, + isset($request_data->qty) ? $request_data->qty : $propalline->qty, + isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent, + isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx, + isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx, + isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx, + isset($request_data->desc) ? $request_data->desc : $propalline->desc, 'HT', - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, + isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits, + isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code, + isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line, 0, - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, - isset($request_data->label)?$request_data->label:$propalline->label, - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice + isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice, + isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht, + isset($request_data->label) ? $request_data->label : $propalline->label, + isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type, + isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start, + isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, + isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, + isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, + isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice ); if ($updateRes > 0) { @@ -438,16 +438,16 @@ class Proposals extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -479,13 +479,13 @@ class Proposals extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if(!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } @@ -493,7 +493,7 @@ class Proposals extends DolibarrApi throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); } - if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -522,17 +522,17 @@ class Proposals extends DolibarrApi */ public function deleteContact($id, $rowid) { - if(!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -555,16 +555,16 @@ class Proposals extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -579,7 +579,7 @@ class Proposals extends DolibarrApi } if (!empty($this->propal->fin_validite)) { - if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0) + if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0) { throw new RestException(500, $this->propal->error); } @@ -604,19 +604,19 @@ class Proposals extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->propal->supprimer) { + if (!DolibarrApiAccess::$user->rights->propal->supprimer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->propal->delete(DolibarrApiAccess::$user)) { + if (!$this->propal->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); } @@ -639,15 +639,15 @@ class Proposals extends DolibarrApi */ public function settodraft($id) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -660,11 +660,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -696,15 +696,15 @@ class Proposals extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -717,11 +717,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -744,15 +744,15 @@ class Proposals extends DolibarrApi */ public function close($id, $status, $note_private = '', $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -765,11 +765,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -789,15 +789,15 @@ class Proposals extends DolibarrApi */ public function setinvoiced($id) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -807,11 +807,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bea546eeae8..9be7f50cbbf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -252,13 +252,13 @@ class Propal extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), @@ -290,7 +290,7 @@ class Propal extends CommonObject 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195), - 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated + 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>215), 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>220), diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index ee42ca26471..d5c48006430 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -24,10 +24,10 @@ * \brief File of class to manage proposals statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; -include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -66,36 +66,36 @@ class PropaleStats extends Stats if ($mode == 'customer') { - $object=new Propal($this->db); + $object = new Propal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date='p.datep'; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field_date = 'p.datep'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - $this->where.= " p.fk_statut > 0"; + $this->where .= " p.fk_statut > 0"; } if ($mode == 'supplier') { - $object=new SupplierProposal($this->db); + $object = new SupplierProposal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date='p.date_valid'; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field_date = 'p.date_valid'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - $this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed + $this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; - $this->where.= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if($this->socid) + $this->where .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($this->socid) { - $this->where.=" AND p.fk_soc = ".$this->socid; + $this->where .= " AND p.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; } @@ -111,14 +111,14 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -133,11 +133,11 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -154,14 +154,14 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -176,12 +176,12 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -196,11 +196,11 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -219,13 +219,13 @@ class PropaleStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; - $sql.= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; + $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 365308a224b..94e68b8bb02 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -167,15 +167,15 @@ $arrayfields = array( 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), - 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), - 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), - 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -344,7 +344,7 @@ if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); @@ -1099,7 +1099,7 @@ if ($resql) // Currency if (!empty($arrayfields['p.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."\n"; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; if (!$i) $totalarray['nbfield']++; } @@ -1107,7 +1107,7 @@ if ($resql) if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 03cdf990071..eb3c165d447 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -118,16 +118,16 @@ class Orders extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id, $ref, $ref_ext); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -163,18 +163,18 @@ class Orders extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."commande as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('commande').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('commande').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -183,23 +183,23 @@ class Orders extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -209,12 +209,12 @@ class Orders extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $commande_static = new Commande($db); - if($commande_static->fetch($obj->rowid)) { + if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($commande_static); @@ -225,7 +225,7 @@ class Orders extends DolibarrApi else { throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No order found'); } return $obj_ret; @@ -239,13 +239,13 @@ class Orders extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->commande->$field = $value; } /*if (isset($request_data["lines"])) { @@ -274,16 +274,16 @@ class Orders extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->commande->getLinesArray(); @@ -306,16 +306,16 @@ class Orders extends DolibarrApi */ public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -368,16 +368,16 @@ class Orders extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -430,16 +430,16 @@ class Orders extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -469,16 +469,16 @@ class Orders extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -507,16 +507,16 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -539,19 +539,19 @@ class Orders extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->commande->$field = $value; } @@ -580,19 +580,19 @@ class Orders extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->commande->supprimer) { + if (!DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->commande->delete(DolibarrApiAccess::$user)) { + if (!$this->commande->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting order : '.$this->commande->error); } @@ -628,15 +628,15 @@ class Orders extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -648,11 +648,11 @@ class Orders extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -681,21 +681,21 @@ class Orders extends DolibarrApi public function reopen($id) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Order ID is mandatory'); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->commande->set_reopen(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->commande->error); - }elseif( $result == 0) { + }elseif ($result == 0) { throw new RestException(304); } @@ -719,28 +719,28 @@ class Orders extends DolibarrApi public function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Order ID is mandatory'); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->commande->classifyBilled(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(400, $this->commande->error); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -761,15 +761,15 @@ class Orders extends DolibarrApi */ public function close($id, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -782,11 +782,11 @@ class Orders extends DolibarrApi } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -807,15 +807,15 @@ class Orders extends DolibarrApi */ public function settodraft($id, $idwarehouse = -1) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -828,11 +828,11 @@ class Orders extends DolibarrApi } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -859,26 +859,26 @@ class Orders extends DolibarrApi public function createOrderFromProposal($proposalid) { - require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($proposalid)) { + if (empty($proposalid)) { throw new RestException(400, 'Proposal ID is mandatory'); } $propal = new Propal($this->db); $result = $propal->fetch($proposalid); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } $result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->commande->error); } $this->commande->fetchObjectLinked(); @@ -921,7 +921,7 @@ class Orders extends DolibarrApi $commande = array(); foreach (Orders::$FIELDS as $field) { if (!isset($data[$field])) - throw new RestException(400, $field ." field missing"); + throw new RestException(400, $field." field missing"); $commande[$field] = $data[$field]; } return $commande; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ddd6d7723d5..a34dcc76377 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -262,12 +262,12 @@ class Commande extends CommonOrder /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25), diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 522bd7b2e31..8b6dc4db6ec 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -23,10 +23,10 @@ * \ingroup commandes * \brief File of class to manage order statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; -include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -67,31 +67,31 @@ class CommandeStats extends Stats if ($mode == 'customer') { - $object=new Commande($this->db); + $object = new Commande($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; - $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; + $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled } elseif ($mode == 'supplier') { - $object=new CommandeFournisseur($this->db); + $object = new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; - $this->where.= " c.fk_statut > 2"; // Only approved & ordered + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; + $this->where .= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= ' AND c.entity IN ('.getEntity('commande').')'; + $this->where .= ' AND c.entity IN ('.getEntity('commande').')'; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { - $this->where.=" AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; } /** @@ -106,14 +106,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -128,11 +128,11 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -149,14 +149,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -171,12 +171,12 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -191,11 +191,11 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -212,13 +212,13 @@ class CommandeStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; + $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5e2353110e7..429a42464d1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -346,7 +346,7 @@ if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1); if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); @@ -1168,7 +1168,7 @@ if ($resql) // Currency if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."\n"; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; if (!$i) $totalarray['nbfield']++; } @@ -1176,7 +1176,7 @@ if ($resql) if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 7a8832be2b5..d1e15c10553 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -133,7 +133,7 @@ if (($action == "searchfiles" || $action == "dl")) { // Customer invoices if (GETPOST('selectinvoices')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; @@ -142,7 +142,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Vendor invoices if (GETPOST('selectsupplierinvoices')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; @@ -151,7 +151,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Expense reports if (GETPOST('selectexpensereports')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; @@ -160,7 +160,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Donations if (GETPOST('selectdonations')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; @@ -169,7 +169,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Paiements of salaries if (GETPOST('selectpaymentsofsalaries')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; @@ -178,7 +178,7 @@ if (($action == "searchfiles" || $action == "dl")) { } // Social contributions if (GETPOST('selectsocialcontributions')) { - if (! empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_creation as date, t.date_ech as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE date_creation between ".$wheretail; @@ -467,7 +467,7 @@ print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($conf->entity); - print '('.$langs->trans("Entity").' : '; + print '('.$langs->trans("Entity").' : '; print ""; if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); @@ -488,8 +488,8 @@ $listofchoices = array( 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'), 'selectsocialcontributions'=>array('label'=>'SocialContributions') ); -foreach($listofchoices as $choice => $val) { - $checked = (((! GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice))?' checked="checked"':''); +foreach ($listofchoices as $choice => $val) { + $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); print '
'.$langs->trans($val['label']).'
'; } @@ -508,8 +508,8 @@ if (!empty($date_start) && !empty($date_stop)) $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); - foreach($listofchoices as $choice => $val) { - $param.='&'.$choice.'='.(GETPOST($choice, 'int')?1:0); + foreach ($listofchoices as $choice => $val) { + $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); } print '
'."\n"; print ''; @@ -518,7 +518,7 @@ if (!empty($date_start) && !empty($date_stop)) print ''; print ''; - foreach($listofchoices as $choice => $val) { + foreach ($listofchoices as $choice => $val) { print ''; } diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 37193726b01..8c146a65470 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -39,17 +39,17 @@ if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categori // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'accountancy', 'compta')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bankaccountlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bankaccountlist'; // To manage different context of search -$search_ref=GETPOST('search_ref', 'alpha'); -$search_label=GETPOST('search_label', 'alpha'); -$search_number=GETPOST('search_number', 'alpha'); -$search_status=GETPOST('search_status')?GETPOST('search_status', 'alpha'):'opened'; // 'all' or ''='opened' +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_number = GETPOST('search_number', 'alpha'); +$search_status = GETPOST('search_status') ?GETPOST('search_status', 'alpha') : 'opened'; // 'all' or ''='opened' $optioncss = GETPOST('optioncss', 'alpha'); if (!empty($conf->categorie->enabled)) @@ -58,13 +58,13 @@ if (!empty($conf->categorie->enabled)) } // Security check -if ($user->socid) $socid=$user->socid; -if (! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with list of banks accounting account allowed to manager of chart account -if (! $allowed) $result=restrictedArea($user, 'banque'); +if ($user->socid) $socid = $user->socid; +if (!empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account +if (!$allowed) $result = restrictedArea($user, 'banque'); -$diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -82,7 +82,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -108,10 +108,10 @@ $arrayfields = array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - 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]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -155,41 +155,41 @@ $accounts = array(); $sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.= $hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_ACCOUNT, "b.rowid"); } -$sql.= " WHERE b.entity IN (".getEntity('bank_account').")"; -if ($search_status == 'opened') $sql.= " AND clos = 0"; -if ($search_status == 'closed') $sql.= " AND clos = 1"; +$sql .= " WHERE b.entity IN (".getEntity('bank_account').")"; +if ($search_status == 'opened') $sql .= " AND clos = 0"; +if ($search_status == 'closed') $sql .= " AND clos = 1"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_ACCOUNT, "b.rowid", $search_category_list); } -if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref); -if ($search_label != '') $sql.=natural_search('b.label', $search_label); -if ($search_number != '') $sql.=natural_search('b.number', $search_number); +if ($search_ref != '') $sql .= natural_search('b.ref', $search_ref); +if ($search_label != '') $sql .= natural_search('b.label', $search_label); +if ($search_number != '') $sql .= natural_search('b.number', $search_number); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -438,52 +438,52 @@ foreach ($accounts as $key=>$type) $solde = $objecttmp->solde(1); - if (! empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) + if (!empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) { - $lastcurrencycode='various'; // We found several different currencies + $lastcurrencycode = 'various'; // We found several different currencies } if ($lastcurrencycode != 'various') { - $lastcurrencycode=$objecttmp->currency_code; + $lastcurrencycode = $objecttmp->currency_code; } print ''; // Ref - if (! empty($arrayfields['b.ref']['checked'])) + if (!empty($arrayfields['b.ref']['checked'])) { print ''.$objecttmp->getNomUrl(1).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['b.label']['checked'])) + if (!empty($arrayfields['b.label']['checked'])) { print ''.$objecttmp->label.''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account type - if (! empty($arrayfields['accountype']['checked'])) + if (!empty($arrayfields['accountype']['checked'])) { print ''; print $objecttmp->type_lib[$objecttmp->type]; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Number - if (! empty($arrayfields['b.number']['checked'])) + if (!empty($arrayfields['b.number']['checked'])) { print ''.$objecttmp->number.''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account number - if (! empty($arrayfields['b.account_number']['checked'])) + if (!empty($arrayfields['b.account_number']['checked'])) { print ''; - if (! empty($conf->accounting->enabled) && ! empty($objecttmp->account_number)) + if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objecttmp->account_number, 1); @@ -494,14 +494,14 @@ foreach ($accounts as $key=>$type) print $objecttmp->account_number; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy journal - if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; - if (! empty($conf->accounting->enabled) && ! empty($objecttmp->fk_accountancy_journal)) + if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objecttmp->fk_accountancy_journal); @@ -547,47 +547,47 @@ foreach ($accounts as $key=>$type) print ''.$langs->trans("FeatureDisabled").''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect 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'])) + if (!empty($arrayfields['b.datec']['checked'])) { print ''; print dol_print_date($objecttmp->date_creation, 'dayhour'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['b.tms']['checked'])) + if (!empty($arrayfields['b.tms']['checked'])) { print ''; print dol_print_date($objecttmp->date_update, 'dayhour'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['b.clos']['checked'])) + if (!empty($arrayfields['b.clos']['checked'])) { print ''.$objecttmp->getLibStatut(5).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Balance - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { print ''; print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).''; print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='balance'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance'; $totalarray['val']['balance'] += $solde; } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index ea180a6b0ee..2229ea22609 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -32,7 +32,7 @@ $langs->loadLangs(array('companies', 'users', 'trips')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'deplacement', '', ''); $sortfield = GETPOST("sortfield", 'alpha'); @@ -42,33 +42,33 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="d.dated"; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.dated"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; /* * View */ -$tripandexpense_static=new Deplacement($db); +$tripandexpense_static = new Deplacement($db); $childids = $user->getAllChildIds(); -$childids[]=$user->id; +$childids[] = $user->id; //$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("ListOfFees"), $help_url); -$totalnb=0; +$totalnb = 0; $sql = "SELECT count(d.rowid) as nb, sum(d.km) as km, d.type"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d"; -$sql.= " WHERE d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -$sql.= " GROUP BY d.type"; -$sql.= " ORDER BY d.type"; +$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d"; +$sql .= " WHERE d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; +$sql .= " GROUP BY d.type"; +$sql .= " ORDER BY d.type"; $result = $db->query($sql); if ($result) @@ -102,10 +102,10 @@ print ''; print ''.$langs->trans("Statistics").''; print "\n"; -$listoftype=$tripandexpense_static->listOfTypes(); +$listoftype = $tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[]=array($label, (isset($nb[$code])?(int) $nb[$code]:0)); + $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); } if ($conf->use_javascript_ajax) @@ -120,7 +120,7 @@ if ($conf->use_javascript_ajax) $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb?0:1); + print $dolgraph->show($totalnb ? 0 : 1); print ''; } @@ -137,25 +137,25 @@ print ''; print '
'; -$max=10; +$max = 10; $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE u.rowid = d.fk_user"; -$sql.= " AND d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND d.fk_soc = ".$socid; -$sql.= $db->order("d.tms", "DESC"); -$sql.= $db->plimit($max, 0); +$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; +if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE u.rowid = d.fk_user"; +$sql .= " AND d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; +if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND d.fk_soc = ".$socid; +$sql .= $db->order("d.tms", "DESC"); +$sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var=false; + $var = false; $num = $db->num_rows($result); $i = 0; @@ -171,16 +171,16 @@ if ($result) { $total_ttc = $totalam = $total = 0; - $deplacementstatic=new Deplacement($db); - $userstatic=new User($db); + $deplacementstatic = new Deplacement($db); + $userstatic = new User($db); while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); - $deplacementstatic->ref=$obj->rowid; - $deplacementstatic->id=$obj->rowid; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; + $deplacementstatic->ref = $obj->rowid; + $deplacementstatic->id = $obj->rowid; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; print ''; print ''.$deplacementstatic->getNomUrl(1).''; print ''.$userstatic->getNomUrl(1).''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8510f1caa16..43e62d4b3a9 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -302,7 +302,7 @@ if (empty($reshook)) // Note: Other solution if you want to add a negative line on invoice, is to create a discount for customer and consumme it (but this is possible on standard invoice only). $array_of_total_ht_per_vat_rate = array(); $array_of_total_ht_devise_per_vat_rate = array(); - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if (empty($array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; if (empty($array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->total_ht; @@ -310,7 +310,7 @@ if (empty($reshook)) } //var_dump($array_of_total_ht_per_vat_rate);exit; - foreach($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue) + foreach ($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue) { $tmp_total_ht = $array_of_total_ht_per_vat_rate[$vatrate]; $tmp_total_ht_devise = $array_of_total_ht_devise_per_vat_rate[$vatrate]; @@ -1524,7 +1524,7 @@ if (empty($reshook)) // If we create a deposit with all lines and a percent, we change amount if ($_POST['type'] == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines') { if (is_array($lines)) { - foreach($lines as $line) { + foreach ($lines as $line) { // We keep ->subprice and ->pa_ht, but we change the qty $line->qty = price2num($line->qty * $valuedeposit / 100, 'MS'); } @@ -5119,7 +5119,7 @@ elseif ($id > 0 || !empty($ref)) } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercancreate - && (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) ) { print ''.$langs->trans('ConvertToReduc').''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b9e80ca1cf8..312c34d0ecb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -117,7 +117,7 @@ class Facture extends CommonInvoice * @var int Ref Int * @deprecated */ - public $ref_int; // deprecated + public $ref_int; // deprecated //Check constants for types public $type = self::TYPE_STANDARD; @@ -261,7 +261,7 @@ class Facture extends CommonInvoice 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>25), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'Ref client', 'enabled'=>1, 'visible'=>-1, 'position'=>40), //'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45), @@ -1499,7 +1499,7 @@ class Facture extends CommonInvoice $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($notused) $sql .= " AND f.ref_int='".$this->db->escape($notused)."'"; // deprecated + if ($notused) $sql .= " AND f.ref_int='".$this->db->escape($notused)."'"; // deprecated } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -2439,9 +2439,9 @@ class Facture extends CommonInvoice $productStatic = null; $warehouseStatic = null; if ($batch_rule > 0) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT . '/product/class/productbatch.class.php'; - require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $productStatic = new Product($this->db); $warehouseStatic = new Entrepot($this->db); } @@ -2621,7 +2621,7 @@ class Facture extends CommonInvoice $langs->load('errors'); $warehouseStatic->fetch($idwarehouse); $this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref); - dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); + dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); } foreach ($batchList as $batch) { @@ -2660,7 +2660,7 @@ class Facture extends CommonInvoice $langs->load('errors'); $warehouseStatic->fetch($idwarehouse); $this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref); - dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); + dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); } } } diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 730df6ee6e4..ea0b17bc59a 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -22,10 +22,10 @@ * \ingroup factures * \brief Fichier de la classe de gestion des stats des factures */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** * Class to manage stats for invoices (customer and supplier) @@ -64,32 +64,32 @@ class FactureStats extends Stats if ($mode == 'customer') { - $object=new Facture($this->db); + $object = new Facture($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total'; - $this->field_line='total_ht'; + $this->field = 'total'; + $this->field_line = 'total_ht'; } if ($mode == 'supplier') { - $object=new FactureFournisseur($this->db); + $object = new FactureFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; } $this->where = " f.fk_statut >= 0"; - $this->where.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) + $this->where .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($mode == 'customer') $this->where .= " AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if ($this->socid) { - $this->where.=" AND f.fk_soc = ".$this->socid; + $this->where .= " AND f.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2,5)"; - else $this->where.= " AND f.type IN (0,1,2,3,5)"; + if ($this->userid > 0) $this->where .= ' AND f.fk_user_author = '.$this->userid; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where .= " AND f.type IN (0,1,2,5)"; + else $this->where .= " AND f.type IN (0,1,2,3,5)"; } @@ -105,14 +105,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(f.datef,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -128,11 +128,11 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(f.datef,'%Y') as dm, COUNT(*), SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -150,14 +150,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -173,12 +173,12 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -193,11 +193,11 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -214,13 +214,13 @@ class FactureStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; - $sql.= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; + $sql .= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 82f92085abf..81607613947 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -477,7 +477,7 @@ if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_v if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND f.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_code != '') $sql .= ' AND f.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); @@ -1402,7 +1402,7 @@ if ($resql) // Currency if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."\n"; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; if (!$i) $totalarray['nbfield']++; } @@ -1410,7 +1410,7 @@ if ($resql) if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 5c8fc84a843..bb5a7516fb2 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -23,18 +23,18 @@ * \brief Code for actions on extrafields admin pages */ -$maxsizestring=255; -$maxsizeint=10; -$mesg=array(); +$maxsizestring = 255; +$maxsizeint = 10; +$mesg = array(); -$extrasize=GETPOST('size', 'intcomma'); -$type=GETPOST('type', 'alpha'); -$param=GETPOST('param', 'alpha'); +$extrasize = GETPOST('size', 'intcomma'); +$type = GETPOST('type', 'alpha'); +$param = GETPOST('param', 'alpha'); -if ($type=='double' && strpos($extrasize, ',')===false) $extrasize='24,8'; -if ($type=='date') $extrasize=''; -if ($type=='datetime') $extrasize=''; -if ($type=='select') $extrasize=''; +if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8'; +if ($type == 'date') $extrasize = ''; +if ($type == 'datetime') $extrasize = ''; +if ($type == 'select') $extrasize = ''; // Add attribute @@ -43,83 +43,83 @@ if ($action == 'add') if ($_POST["button"] != $langs->trans("Cancel")) { // Check values - if (! $type) + if (!$type) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'create'; } - if ($type=='varchar' && $extrasize <= 0) + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type=='varchar' && $extrasize > $maxsizestring) + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'create'; } - if ($type=='int' && $extrasize > $maxsizeint) + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'create'; } - if ($type=='select' && !$param) + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } - if ($type=='sellist' && !$param) + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } - if ($type=='checkbox' && !$param) + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } - if ($type=='link' && !$param) + if ($type == 'link' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForLinkType"); + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } - if ($type=='radio' && !$param) + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } - if ((($type=='radio') || ($type=='checkbox')) && $param) + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { if (preg_match_all('/,/', $param_ligne, $matches)) { - if (count($matches[0])>1) { + if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } @@ -127,14 +127,14 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } } } - if (! $error) + if (!$error) { // attrname must be alphabetical and lower case only if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) @@ -144,8 +144,8 @@ if ($action == 'add') $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression - if ($type=='sellist') { - foreach($parameters_array as $param_ligne) + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } @@ -153,37 +153,37 @@ if ($action == 'add') else { //Esle it's separated key/value and coma list - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { - list($key,$value) = explode(',', $param_ligne); + list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } } // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility=3; + if ($type == 'separate') $visibility = 3; - $result=$extrafields->addExtraField( + $result = $extrafields->addExtraField( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, GETPOST('pos', 'int'), $extrasize, $elementtype, - (GETPOST('unique', 'alpha')?1:0), - (GETPOST('required', 'alpha')?1:0), + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), $default_value, $params, - (GETPOST('alwayseditable', 'alpha')?1:0), - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), $visibility, GETPOST('help', 'alpha'), GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:''), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile', 'alpha'), 1, - (GETPOST('totalizable', 'alpha')?1:0), + (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); if ($result > 0) @@ -195,7 +195,7 @@ if ($action == 'add') else { $error++; - $mesg=$extrafields->error; + $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } } @@ -203,7 +203,7 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); $action = 'create'; } @@ -221,76 +221,76 @@ if ($action == 'update') if ($_POST["button"] != $langs->trans("Cancel")) { // Check values - if (! $type) + if (!$type) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'edit'; } - if ($type=='varchar' && $extrasize <= 0) + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type=='varchar' && $extrasize > $maxsizestring) + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'edit'; } - if ($type=='int' && $extrasize > $maxsizeint) + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'edit'; } - if ($type=='select' && !$param) + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } - if ($type=='sellist' && !$param) + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } - if ($type=='checkbox' && !$param) + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } - if ($type=='radio' && !$param) + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'edit'; } - if ((($type=='radio') || ($type=='checkbox')) && $param) + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { if (preg_match_all('/,/', $param_ligne, $matches)) { - if (count($matches[0])>1) { + if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } @@ -298,14 +298,14 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } } } - if (! $error) + if (!$error) { if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) { @@ -314,8 +314,8 @@ if ($action == 'update') $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression - if ($type=='sellist') { - foreach($parameters_array as $param_ligne) + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } @@ -323,37 +323,37 @@ if ($action == 'update') else { //Esle it's separated key/value and coma list - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { - list($key,$value) = explode(',', $param_ligne); + list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } } // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility=3; + if ($type == 'separate') $visibility = 3; - $result=$extrafields->update( + $result = $extrafields->update( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, $extrasize, $elementtype, - (GETPOST('unique', 'alpha')?1:0), - (GETPOST('required', 'alpha')?1:0), + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), $pos, $params, - (GETPOST('alwayseditable', 'alpha')?1:0), - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), $visibility, GETPOST('help', 'alpha'), GETPOST('default_value', 'alpha'), GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:''), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), 1, - (GETPOST('totalizable', 'alpha')?1:0), + (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); if ($result > 0) @@ -365,7 +365,7 @@ if ($action == 'update') else { $error++; - $mesg=$extrafields->error; + $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } } @@ -373,7 +373,7 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); } } @@ -387,20 +387,20 @@ if ($action == 'update') // Delete attribute if ($action == 'delete') { - if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) + if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) { - $result=$extrafields->delete($_GET["attrname"], $elementtype); + $result = $extrafields->delete($_GET["attrname"], $elementtype); if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } - else $mesg=$extrafields->error; + else $mesg = $extrafields->error; } else { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 3447b76a2b7..e8337d74303 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -163,7 +163,7 @@ class box_graph_product_distribution extends ModeleBoxes { $i = 0; $legend = array(); - foreach($data1 as $key => $val) + foreach ($data1 as $key => $val) { $data1[$key][0] = dol_trunc($data1[$key][0], 32); $legend[] = $data1[$key][0]; @@ -222,7 +222,7 @@ class box_graph_product_distribution extends ModeleBoxes { $i = 0; $legend = array(); - foreach($data2 as $key => $val) + foreach ($data2 as $key => $val) { $data2[$key][0] = dol_trunc($data2[$key][0], 32); $legend[] = $data2[$key][0]; @@ -282,7 +282,7 @@ class box_graph_product_distribution extends ModeleBoxes { $i = 0; $legend = array(); - foreach($data3 as $key => $val) + foreach ($data3 as $key => $val) { $data3[$key][0] = dol_trunc($data3[$key][0], 32); $legend[] = $data3[$key][0]; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 68f2e9b1ba8..80c6ff1b7a6 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -36,7 +36,7 @@ class Canvas /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -45,13 +45,13 @@ class Canvas public $actiontype; - public $dirmodule; // Module directory - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) - public $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory - public $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance /** @@ -76,9 +76,9 @@ class Canvas private function _cleanaction($action) { $newaction = $action; - if ($newaction == 'add') $newaction='create'; - if ($newaction == 'update') $newaction='edit'; - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; + if ($newaction == 'add') $newaction = 'create'; + if ($newaction == 'update') $newaction = 'edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; return $newaction; } @@ -114,7 +114,7 @@ class Canvas if (file_exists($controlclassfile)) { // Include actions class (controller) - $this->control_file=$controlclassfile; + $this->control_file = $controlclassfile; require_once $controlclassfile; // Instantiate actions class (controller) @@ -124,9 +124,9 @@ class Canvas // Template dir $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); - if (! is_dir($this->template_dir)) + if (!is_dir($this->template_dir)) { - $this->template_dir=''; + $this->template_dir = ''; } //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; @@ -158,7 +158,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -177,7 +177,7 @@ class Canvas global $form, $formfile; //var_dump($this->card.'-'.$action); - include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index b0001a695b8..6f151698cfc 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -221,24 +221,24 @@ abstract class CommonDocGenerator ); // Retrieve extrafields - if(is_array($object->array_options) && count($object->array_options)) + if (is_array($object->array_options) && count($object->array_options)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); + $array_thirdparty = array_merge($array_thirdparty, array('company_options_'.$key => $object->array_options ['options_'.$key])); } } return $array_thirdparty; @@ -258,61 +258,61 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - if(empty($object->country) && ! empty($object->country_code)) + if (empty($object->country) && !empty($object->country_code)) { - $object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code); + $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); } - if(empty($object->state) && ! empty($object->state_code)) + if (empty($object->state) && !empty($object->state_code)) { $object->state = getState($object->state_code, 0); } - $array_contact = array ( - $array_key . '_fullname' => $object->getFullName($outputlangs, 1), - $array_key . '_lastname' => $object->lastname, - $array_key . '_firstname' => $object->firstname, - $array_key . '_address' => $object->address, - $array_key . '_zip' => $object->zip, - $array_key . '_town' => $object->town, - $array_key . '_state_id' => $object->state_id, - $array_key . '_state_code' => $object->state_code, - $array_key . '_state' => $object->state, - $array_key . '_country_id' => $object->country_id, - $array_key . '_country_code' => $object->country_code, - $array_key . '_country' => $object->country, - $array_key . '_poste' => $object->poste, - $array_key . '_socid' => $object->socid, - $array_key . '_statut' => $object->statut, - $array_key . '_code' => $object->code, - $array_key . '_email' => $object->email, - $array_key . '_jabberid' => $object->jabberid, - $array_key . '_phone_pro' => $object->phone_pro, - $array_key . '_phone_perso' => $object->phone_perso, - $array_key . '_phone_mobile' => $object->phone_mobile, - $array_key . '_fax' => $object->fax, - $array_key . '_birthday' => $object->birthday, - $array_key . '_default_lang' => $object->default_lang, - $array_key . '_note_public' => $object->note_public, - $array_key . '_note_private' => $object->note_private + $array_contact = array( + $array_key.'_fullname' => $object->getFullName($outputlangs, 1), + $array_key.'_lastname' => $object->lastname, + $array_key.'_firstname' => $object->firstname, + $array_key.'_address' => $object->address, + $array_key.'_zip' => $object->zip, + $array_key.'_town' => $object->town, + $array_key.'_state_id' => $object->state_id, + $array_key.'_state_code' => $object->state_code, + $array_key.'_state' => $object->state, + $array_key.'_country_id' => $object->country_id, + $array_key.'_country_code' => $object->country_code, + $array_key.'_country' => $object->country, + $array_key.'_poste' => $object->poste, + $array_key.'_socid' => $object->socid, + $array_key.'_statut' => $object->statut, + $array_key.'_code' => $object->code, + $array_key.'_email' => $object->email, + $array_key.'_jabberid' => $object->jabberid, + $array_key.'_phone_pro' => $object->phone_pro, + $array_key.'_phone_perso' => $object->phone_perso, + $array_key.'_phone_mobile' => $object->phone_mobile, + $array_key.'_fax' => $object->fax, + $array_key.'_birthday' => $object->birthday, + $array_key.'_default_lang' => $object->default_lang, + $array_key.'_note_public' => $object->note_public, + $array_key.'_note_private' => $object->note_private ); // Retrieve extrafields - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { - $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); + $object->array_options['options_'.$key] = price($object->array_options ['options_'.$key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_' . $key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_' . $key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); + $array_contact = array_merge($array_contact, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); } return $array_contact; } @@ -478,20 +478,20 @@ abstract class CommonDocGenerator } // Add vat by rates - if (is_array($object->lines) && count($object->lines)>0) + if (is_array($object->lines) && count($object->lines) > 0) { $totalUp = 0; foreach ($object->lines as $line) { // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward compatibility - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0; + $resarray[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx] = price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) - $vatformated=vatrate($line->tva_tx); - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + $vatformated = vatrate($line->tva_tx); + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated] = 0; + $resarray[$array_key.'_total_vat_'.$vatformated] += $line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$vatformated] = price($resarray[$array_key.'_total_vat_'.$vatformated]); $totalUp += $line->subprice * $line->qty; } @@ -589,13 +589,13 @@ abstract class CommonDocGenerator // Units if ($conf->global->PRODUCT_USE_UNITS) { - $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); - $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); + $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); + $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); } // Retrieve extrafields - $extrafieldkey=$line->element; - $array_key="line"; + $extrafieldkey = $line->element; + $array_key = "line"; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($extrafieldkey, true); @@ -608,7 +608,7 @@ abstract class CommonDocGenerator { // Add the product supplier extrafields to the substitutions $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; if (!empty($extralabels) && is_array($extralabels)) { @@ -622,7 +622,7 @@ abstract class CommonDocGenerator if ($columns != "") { $columns = substr($columns, 0, strlen($columns) - 2); - $resql = $this->db->query("SELECT $columns FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '" . $line->ref_supplier . "'"); + $resql = $this->db->query("SELECT $columns FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields AS ex INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$line->ref_supplier."'"); if ($this->db->num_rows($resql) > 0) { @@ -737,14 +737,14 @@ abstract class CommonDocGenerator 'line_qty'=>$line->qty, 'line_qty_shipped'=>$line->qty_shipped, 'line_qty_asked'=>$line->qty_asked, - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), + 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.'%' : ''), 'line_price_ht'=>price($line->total_ht), 'line_price_ttc'=>price($line->total_ttc), 'line_price_vat'=>price($line->total_tva), - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), + 'line_weight'=>empty($line->weight) ? '' : $line->weight * $line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), + 'line_length'=>empty($line->length) ? '' : $line->length * $line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), + 'line_surface'=>empty($line->surface) ? '' : $line->surface * $line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), + 'line_volume'=>empty($line->volume) ? '' : $line->volume * $line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), ); // Retrieve extrafields @@ -807,37 +807,37 @@ abstract class CommonDocGenerator global $conf; if (is_array($extrafields->attributes[$object->table_element]['label'])) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); //Add value to store price with currency - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $valArray=explode(',', $object->array_options['options_'.$key]); - $output=array(); - foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { - if (in_array($keyopt, $valArray)) { - $output[]=$valopt; + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { + $valArray = explode(',', $object->array_options['options_'.$key]); + $output = array(); + foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { + if (in_array($keyopt, $valArray)) { + $output[] = $valopt; } } $object->array_options['options_'.$key] = implode(', ', $output); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { - if (strlen($object->array_options['options_'.$key])>0) + if (strlen($object->array_options['options_'.$key]) > 0) { $date = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language - $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format - $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format + $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language + $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format + $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format } else { @@ -845,29 +845,29 @@ abstract class CommonDocGenerator $object->array_options['options_'.$key.'_locale'] = ''; $object->array_options['options_'.$key.'_rfc'] = ''; } - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') + elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language - $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format - $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + $object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language + $object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format + $object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : ''); // international format + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { $id = $object->array_options['options_'.$key]; if ($id != "") { $param = $extrafields->attributes[$object->table_element]['param'][$key]; - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' $InfoFieldList = explode(":", $param_list[0]); - $classname=$InfoFieldList[0]; - $classpath=$InfoFieldList[1]; - if (! empty($classpath)) + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if (!empty($classpath)) { dol_include_once($InfoFieldList[1]); if ($classname && class_exists($classname)) @@ -948,27 +948,27 @@ abstract class CommonDocGenerator uasort($this->cols, array($this, 'columnSort')); // Positionning - $curX = $this->page_largeur-$this->marge_droite; // start from right + $curX = $this->page_largeur - $this->marge_droite; // start from right // Array width - $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche; + $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche; // Count flexible column $totalDefinedColWidth = 0; $countFlexCol = 0; foreach ($this->cols as $colKey =>& $colDef) { - if(!$this->getColumnStatus($colKey)) continue; // continue if disabled + if (!$this->getColumnStatus($colKey)) continue; // continue if disabled - if(!empty($colDef['scale'])){ + if (!empty($colDef['scale'])) { // In case of column width is defined by percentage $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100); } - if(empty($colDef['width'])){ + if (empty($colDef['width'])) { $countFlexCol++; } - else{ + else { $totalDefinedColWidth += $colDef['width']; } } @@ -1161,7 +1161,7 @@ abstract class CommonDocGenerator 'printableEnableNotEmpty' => array(4) ); $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ + if (!empty($extrafieldDesc)) { $this->printStdColumnContent($pdf, $posYAfterDescription, $colKey, $extrafieldDesc); } } @@ -1178,13 +1178,13 @@ abstract class CommonDocGenerator { global $hookmanager; - if(empty($object->table_element)){ return; } + if (empty($object->table_element)) { return; } $extrafieldsKeyPrefix = "options_"; // Cleanup extrafield key to remove prefix if present $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix); - if($pos===0){ + if ($pos === 0) { $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix)); } @@ -1192,14 +1192,14 @@ abstract class CommonDocGenerator // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); // TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ... - if($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link'){ + if ($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link') { // for lack of anything better we cleanup all html tags $extrafieldOutputContent = dol_string_nohtmltag($extrafieldOutputContent); } @@ -1233,13 +1233,13 @@ abstract class CommonDocGenerator { global $hookmanager; - if(empty($object->table_element)){ + if (empty($object->table_element)) { return; } // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; $defaultParams = array( @@ -1283,9 +1283,9 @@ abstract class CommonDocGenerator // Enable extrafield ? $enabled = 0; $disableOnEmpty = 0; - if(!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); - if(in_array($printable, $params['printableEnable']) || in_array($printable, $params['printableEnableNotEmpty']) ) { + if (in_array($printable, $params['printableEnable']) || in_array($printable, $params['printableEnableNotEmpty'])) { $enabled = 1; } @@ -1294,7 +1294,7 @@ abstract class CommonDocGenerator } } - if(empty($enabled)){ + if (empty($enabled)) { continue; } @@ -1305,7 +1305,7 @@ abstract class CommonDocGenerator $field->type = $extrafields->attributes[$object->table_element]['type'][$key]; // dont display if empty - if($disableOnEmpty && empty($field->content)) { + if ($disableOnEmpty && empty($field->content)) { continue; } @@ -1313,40 +1313,40 @@ abstract class CommonDocGenerator } } - if(!empty($fields)) + if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function ($a, $b) { + uasort($fields, function($a, $b) { return ($a->rank > $b->rank) ? -1 : 1; }); // define some HTML content with style - $html.= !empty($params['style'])?'':''; + $html .= !empty($params['style']) ? '' : ''; // auto select display format - if($params['display'] == 'auto') { + if ($params['display'] == 'auto') { $lastNnumbItems = 0; - foreach ($params['auto'] as $display => $numbItems){ - if($lastNnumbItems <= $numbItems && count($fields) > $numbItems){ + foreach ($params['auto'] as $display => $numbItems) { + if ($lastNnumbItems <= $numbItems && count($fields) > $numbItems) { $lastNnumbItems = $numbItems; $params['display'] = $display; } } } - if($params['display'] == 'list') { + if ($params['display'] == 'list') { // Display in list format - $i=0; + $i = 0; foreach ($fields as $field) { - $html .= !empty($i)?$params['list']['separator']:''; - $html .= '' . $field->label . ' : '; + $html .= !empty($i) ? $params['list']['separator'] : ''; + $html .= ''.$field->label.' : '; $html .= $field->content; $i++; } } - elseif($params['display'] == 'table') { + elseif ($params['display'] == 'table') { // Display in table format - $html .= ''; + $html .= '
'; $html .= ""; $itemsInRow = 0; @@ -1373,14 +1373,14 @@ abstract class CommonDocGenerator } $itemsInRow = $maxItemsInRow; - $html .= '"; } else { $itemsInRow++; $html .= '"; @@ -1460,7 +1460,7 @@ abstract class CommonDocGenerator // set cell padding with column title definition $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], 0.5); } - else{ + else { // set cell padding with column title definition $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], $colDef['title']['padding'][2]); } @@ -1501,17 +1501,17 @@ abstract class CommonDocGenerator { global $conf; - if(!empty($hidedetails)){ + if (!empty($hidedetails)) { return; } - if(empty($object->table_element)){ + if (empty($object->table_element)) { return; } // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; @@ -1526,15 +1526,15 @@ abstract class CommonDocGenerator // Enable extrafield ? $enabled = 0; - if(!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); - if($printable === 1 || $printable === 2) { + if ($printable === 1 || $printable === 2) { $enabled = 1; } // Note : if $printable === 3 or 4 so, it's displayed after line description not in cols } - if (!$enabled){ continue; } // don't wast resourses if we don't need them... + if (!$enabled) { continue; } // don't wast resourses if we don't need them... // Load language if required if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); @@ -1556,12 +1556,12 @@ abstract class CommonDocGenerator ); $alignTypeRight = array('double', 'int', 'price'); - if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)){ + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)) { $def['content']['align'] = 'R'; } - $alignTypeLeft = array('text', 'html'); - if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)){ + $alignTypeLeft = array('text', 'html'); + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)) { $def['content']['align'] = 'L'; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index c715f53194a..9a804256dac 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -683,7 +683,7 @@ class Conf if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0; - if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library + if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 8edad43dce0..d59ab8ce6bc 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -115,7 +115,7 @@ class DolGraph $this->_library = $library; if ($this->_library == 'auto') { - $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'jflot': $conf->global->MAIN_JS_GRAPH); + $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'jflot' : $conf->global->MAIN_JS_GRAPH); } } @@ -535,7 +535,7 @@ class DolGraph public function GetMaxValueInData() { // phpcs:enable - if (! is_array($this->data)) return 0; + if (!is_array($this->data)) return 0; $k = 0; $vals = array(); @@ -564,7 +564,7 @@ class DolGraph public function GetMinValueInData() { // phpcs:enable - if (! is_array($this->data)) return 0; + if (!is_array($this->data)) return 0; $k = 0; $vals = array(); @@ -748,9 +748,9 @@ class DolGraph } // Start the div that will contains all the graph - $dolxaxisvertical=''; - if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical'; - $this->stringtoshow .= '
'."\n"; + $dolxaxisvertical = ''; + if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; + $this->stringtoshow .= '
'."\n"; $this->stringtoshow .= ''."\n"; @@ -607,8 +607,8 @@ function getStructuredData($type, $data = array()) elseif ($type == 'product') { $ret = ''."\n"; - $ret.= ''."\n"; + $ret .= ''."\n"; } return $ret; } @@ -656,55 +656,55 @@ function getStructuredData($type, $data = array()) */ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) { - global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. + global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. $error = 0; $arrayresult = array('code'=>'', 'list'=>array()); - if (! is_object($weblangs)) $weblangs = $langs; + if (!is_object($weblangs)) $weblangs = $langs; if (empty($searchstring)) { $error++; - $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("EmptySearchString"); + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = $weblangs->trans("EmptySearchString"); } elseif (dol_strlen($searchstring) < 2) { $weblangs->load("errors"); $error++; - $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("ErrorSearchCriteriaTooSmall"); + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = $weblangs->trans("ErrorSearchCriteriaTooSmall"); } - elseif (! in_array($type, array('', 'page'))) + elseif (!in_array($type, array('', 'page'))) { $error++; - $arrayresult['code']='KO'; - $arrayresult['message']='Bad value for parameter $type'; + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = 'Bad value for parameter $type'; } $searchdone = 0; $found = 0; - if (! $error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo))) + if (!$error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo))) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page'; - $sql.= " WHERE fk_website = ".$website->id; - if ($type) $sql.= " AND type_container = '".$db->escape($type)."'"; - $sql.= " AND ("; + $sql .= " WHERE fk_website = ".$website->id; + if ($type) $sql .= " AND type_container = '".$db->escape($type)."'"; + $sql .= " AND ("; $searchalgo = ''; if (preg_match('/meta/', $algo)) { - $searchalgo.= ($searchalgo?' OR ':'')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'"; - $searchalgo.= ($searchalgo?' OR ':'')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords + $searchalgo .= ($searchalgo ? ' OR ' : '')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords } if (preg_match('/content/', $algo)) { - $searchalgo.= ($searchalgo?' OR ':'')."content LIKE '%".$db->escape($searchstring)."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."content LIKE '%".$db->escape($searchstring)."%'"; } - $sql.=$searchalgo; - $sql.= ")"; - $sql.= $db->plimit($max); + $sql .= $searchalgo; + $sql .= ")"; + $sql .= $db->plimit($max); $resql = $db->query($sql); if ($resql) @@ -716,7 +716,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) { $tmpwebsitepage = new WebsitePage($db); $tmpwebsitepage->fetch($obj->rowid); - if ($tmpwebsitepage->id > 0) $arrayresult['list'][]=$tmpwebsitepage; + if ($tmpwebsitepage->id > 0) $arrayresult['list'][] = $tmpwebsitepage; $found++; } $i++; @@ -725,69 +725,69 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) else { $error++; - $arrayresult['code']=$db->lasterrno(); - $arrayresult['message']=$db->lasterror(); + $arrayresult['code'] = $db->lasterrno(); + $arrayresult['message'] = $db->lasterror(); } $searchdone = 1; } - if (! $error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) + if (!$error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) { global $dolibarr_main_data_root; - $pathofwebsite=$dolibarr_main_data_root.'/website/'.$website->ref; - $filehtmlheader=$pathofwebsite.'/htmlheader.html'; - $filecss=$pathofwebsite.'/styles.css.php'; - $filejs=$pathofwebsite.'/javascript.js.php'; - $filerobot=$pathofwebsite.'/robots.txt'; - $filehtaccess=$pathofwebsite.'/.htaccess'; - $filemanifestjson=$pathofwebsite.'/manifest.json.php'; - $filereadme=$pathofwebsite.'/README.md'; + $pathofwebsite = $dolibarr_main_data_root.'/website/'.$website->ref; + $filehtmlheader = $pathofwebsite.'/htmlheader.html'; + $filecss = $pathofwebsite.'/styles.css.php'; + $filejs = $pathofwebsite.'/javascript.js.php'; + $filerobot = $pathofwebsite.'/robots.txt'; + $filehtaccess = $pathofwebsite.'/.htaccess'; + $filemanifestjson = $pathofwebsite.'/manifest.json.php'; + $filereadme = $pathofwebsite.'/README.md'; $filecontent = file_get_contents($filehtmlheader); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_htmlheadercontent'); + $arrayresult['list'][] = array('type'=>'website_htmlheadercontent'); } $filecontent = file_get_contents($filecss); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_csscontent'); + $arrayresult['list'][] = array('type'=>'website_csscontent'); } $filecontent = file_get_contents($filejs); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_jscontent'); + $arrayresult['list'][] = array('type'=>'website_jscontent'); } $filerobot = file_get_contents($filerobot); if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $arrayresult['list'][]=array('type'=>'website_robotcontent'); + $arrayresult['list'][] = array('type'=>'website_robotcontent'); } $searchdone = 1; } - if (! $error) + if (!$error) { if ($searchdone) { - $arrayresult['code']='OK'; + $arrayresult['code'] = 'OK'; if (empty($arrayresult['list'])) { - $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("NoRecordFound"); + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = $weblangs->trans("NoRecordFound"); } } else { $error++; - $arrayresult['code']='KO'; - $arrayresult['message']='No supported algorithm found'; + $arrayresult['code'] = 'KO'; + $arrayresult['message'] = 'No supported algorithm found'; } } diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 5e8711e09d1..de51783b7f1 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -184,7 +184,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) else dol_print_error($db); } // Add canonical reference - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; // Add manifest.json on homepage $tplcontent .= 'use_manifest) { print \'\'."\n"; } ?>'."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4f9558de8ae..87f11decb5e 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -169,214 +169,214 @@ class modProduct extends DolibarrModules // Exports //-------- - $r=0; + $r = 0; $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", - 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", - 'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", + 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", + 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.length_units'=>"LengthUnits", 'p.width'=>"Width", 'p.width_units'=>"WidthUnits", 'p.height'=>"Height", 'p.height_units'=>"HeightUnits", 'p.surface'=>"Surface", 'p.surface_units'=>"SurfaceUnits", 'p.volume'=>"Volume", 'p.volume_units'=>"VolumeUnits", 'p.duration'=>"Duration", 'p.finished' => 'Nature', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', - 'p.datec'=>'DateCreation','p.tms'=>'DateModification' + 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text", - 'p.fk_product_type'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.description'=>"Text",'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text",'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", + if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", + 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.duration'=>"Text", 'p.finished' => 'Numeric', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric', - 'p.datec'=>'Date','p.tms'=>'Date' + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); - $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); + $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; + if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", // 'p.datec'=>'Date','p.tms'=>'Date' //); - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", - 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", + 'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.recuperableonly'=>'product', 'pr.date_price'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 's.nom'=>'ThirdParty', 'pr.price_base_type'=>"PriceBase", - 'pr.price'=>"PriceUnitPriceHT",'pr.price_ttc'=>"PriceUnitPriceTTC", - 'pr.price_min'=>"MinPriceUnitPriceHT",'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", 'pr.tva_tx'=>'PriceVATRate', 'pr.default_vat_code'=>'PriceVATCode', 'pr.datec'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 's.nom'=>'company', - 'pr.price_base_type'=>"product",'pr.price'=>"product", + 'pr.price_base_type'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.default_vat_code'=>'product', 'pr.recuperableonly'=>'product', 'pr.datec'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Exports virtual products $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode",'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text",'p.accountancy_code_buy_intra'=>"Text",'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.datec'=>'Date','p.tms'=>'Date' + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r]=array( - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_sell_intra'=>'virtualproduct','p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct','p.accountancy_code_buy_intra'=>'virtualproduct','p.accountancy_code_buy_export'=>'virtualproduct', - 'p.note'=>"virtualproduct",'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r] = array( + 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", + 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" ); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } // Imports //-------- - $r=0; + $r = 0; // Import list of products $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Products"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); - $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Products"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon + $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); + $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array( 'p.ref' => "Ref*", 'p.label' => "Label*", 'p.fk_product_type' => "Type*", @@ -576,7 +576,7 @@ class modProduct extends DolibarrModules ) ); - if (! is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); + if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( 'p.fk_unit' => array( 'rule' => 'fetchidfromcodeorlabel', diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 822c6bf699f..e99f94aa154 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -136,216 +136,216 @@ class modService extends DolibarrModules // Exports //-------- - $r=0; + $r = 0; $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", - 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", - 'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("service", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", + 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", + 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.duration'=>"Duration", 'p.finished' => 'Nature', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', - 'p.datec'=>'DateCreation','p.tms'=>'DateModification' + 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text", - 'p.fk_product_type'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", - 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + if (!empty($conf->fournisseur->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription', 'l.note'=>'TranslatedNote')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", + 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", + 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.duration'=>"Text", 'p.finished' => 'Numeric', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric', - 'p.datec'=>'Date','p.tms'=>'Date' + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); - $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'product','p.pmp'=>'product')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + if (!empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text', 'l.description'=>'Text', 'l.note'=>'Text')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); + $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); + if (!empty($conf->fournisseur->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation', 'l.description'=>'translation', 'l.note'=>'translation')); + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array('category'=>'p.rowid'); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; + if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; + if (!empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; + $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; + if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; //$this->export_TypeFields_array[$r]=array( // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", // 'p.datec'=>'Date','p.tms'=>'Date' //); - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", - 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", + 'pr.price_base_type'=>"product", 'pr.price_level'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.recuperableonly'=>'product', 'pr.date_price'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // Exports product multiprice $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 's.nom'=>'ThirdParty', 'pr.price_base_type'=>"PriceBase", - 'pr.price'=>"PriceUnitPriceHT",'pr.price_ttc'=>"PriceUnitPriceTTC", - 'pr.price_min'=>"MinPriceUnitPriceHT",'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", 'pr.tva_tx'=>'PriceVATRate', 'pr.default_vat_code'=>'PriceVATCode', 'pr.datec'=>'DateCreation'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR'; + $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product", 's.nom'=>'company', - 'pr.price_base_type'=>"product",'pr.price'=>"product", + 'pr.price_base_type'=>"product", 'pr.price'=>"product", 'pr.price_ttc'=>"product", - 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', 'pr.default_vat_code'=>'product', 'pr.recuperableonly'=>'product', 'pr.datec'=>"product"); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Exports virtual products $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode",'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", - 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("produit", "export")); + $this->export_fields_array[$r] = array( + 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification' ); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text",'p.accountancy_code_buy_intra'=>"Text",'p.accountancy_code_buy_export'=>"Text", - 'p.note'=>"Text",'p.note_public'=>"Text", - 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.datec'=>'Date','p.tms'=>'Date' + if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue')); + if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r] = array( + 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", + 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.note'=>"Text", 'p.note_public'=>"Text", + 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', + 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", + 'p.datec'=>'Date', 'p.tms'=>'Date' ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r]=array( - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_sell_intra'=>'virtualproduct','p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct','p.accountancy_code_buy_intra'=>'virtualproduct','p.accountancy_code_buy_export'=>'virtualproduct', - 'p.note'=>"virtualproduct",'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" + if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric')); + if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r] = array( + 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", + 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct" ); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct')); + if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } } // Imports //-------- - $r=0; + $r = 0; // Import list of services $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Products"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); - $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Products"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon + $this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields'); + $this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array( 'p.ref' => "Ref*", 'p.label' => "Label*", 'p.fk_product_type' => "Type*", @@ -543,7 +543,7 @@ class modService extends DolibarrModules ) ); - if (! is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); + if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( 'p.fk_unit' => array( 'rule' => 'fetchidfromcodeorlabel', diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 8859ce4ba9d..6c25b5c07b5 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -28,7 +28,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -154,7 +154,7 @@ $langs->load("modulebuilder"); selectarray('type', $type2label, GETPOST('type', 'alpha')); ?> - + - +global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> - + - + - + - + - + + - +multicompany->enabled) { ?> - +
'; - $html .= '' . $field->label . ' : '; + $html .= ''; + $html .= ''.$field->label.' : '; $html .= $field->content; $html .= "'; - $html .= '' . $field->label . ' :'; + $html .= ''.$field->label.' :'; $html .= "
trans("Size"); ?>
trans("Size"); ?>
@@ -176,36 +176,36 @@ $langs->load("modulebuilder");
trans("Position"); ?>
trans("Position"); ?>
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("Unique"); ?>>
trans("Unique"); ?>>
trans("Required"); ?>>
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("AlwaysEditable"); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> -
textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
trans("Totalizable"); ?>>
trans("Totalizable"); ?>>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
trans("AllEntities"); ?>>
trans("AllEntities"); ?>>
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 4dc47bbf031..d0eaaec25f2 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -27,7 +27,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -54,7 +54,7 @@ $langs->load("modulebuilder"); var list = jQuery("#list"); var totalizable = jQuery("#totalizable"); load("modulebuilder"); attributes[$elementtype]['label'][$attrname]; -$type=$extrafields->attributes[$elementtype]['type'][$attrname]; -$size=$extrafields->attributes[$elementtype]['size'][$attrname]; -$computed=$extrafields->attributes[$elementtype]['computed'][$attrname]; -$default=$extrafields->attributes[$elementtype]['default'][$attrname]; -$unique=$extrafields->attributes[$elementtype]['unique'][$attrname]; -$required=$extrafields->attributes[$elementtype]['required'][$attrname]; -$pos=$extrafields->attributes[$elementtype]['pos'][$attrname]; -$alwayseditable=$extrafields->attributes[$elementtype]['alwayseditable'][$attrname]; -$param=$extrafields->attributes[$elementtype]['param'][$attrname]; -$perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; -$langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; -$list=$extrafields->attributes[$elementtype]['list'][$attrname]; +$label = $extrafields->attributes[$elementtype]['label'][$attrname]; +$type = $extrafields->attributes[$elementtype]['type'][$attrname]; +$size = $extrafields->attributes[$elementtype]['size'][$attrname]; +$computed = $extrafields->attributes[$elementtype]['computed'][$attrname]; +$default = $extrafields->attributes[$elementtype]['default'][$attrname]; +$unique = $extrafields->attributes[$elementtype]['unique'][$attrname]; +$required = $extrafields->attributes[$elementtype]['required'][$attrname]; +$pos = $extrafields->attributes[$elementtype]['pos'][$attrname]; +$alwayseditable = $extrafields->attributes[$elementtype]['alwayseditable'][$attrname]; +$param = $extrafields->attributes[$elementtype]['param'][$attrname]; +$perms = $extrafields->attributes[$elementtype]['perms'][$attrname]; +$langfile = $extrafields->attributes[$elementtype]['langfile'][$attrname]; +$list = $extrafields->attributes[$elementtype]['list'][$attrname]; $totalizable = $extrafields->attributes[$elementtype]['totalizable'][$attrname]; -$help=$extrafields->attributes[$elementtype]['help'][$attrname]; -$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; -$printable=$extrafields->attributes[$elementtype]['printable'][$attrname]; +$help = $extrafields->attributes[$elementtype]['help'][$attrname]; +$entitycurrentorall = $extrafields->attributes[$elementtype]['entityid'][$attrname]; +$printable = $extrafields->attributes[$elementtype]['printable'][$attrname]; -if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) +if ((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { $param_chain = ''; foreach ($param['options'] as $key => $value) { - if(strlen($key)) + if (strlen($key)) { $param_chain .= $key.','.$value."\n"; } } } -elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate')) +elseif (($type == 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate')) { - $paramlist=array_keys($param['options']); + $paramlist = array_keys($param['options']); $param_chain = $paramlist[0]; } ?> @@ -192,10 +192,10 @@ elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($t - + - +global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> @@ -257,23 +257,23 @@ else - + - + - + + - +multicompany->enabled) { ?> - +
trans("Type"); ?> array('varchar', 'phone', 'mail', 'url', 'select', 'password', 'text', 'html'), - 'text'=>array('text','html'), - 'html'=>array('text','html'), + 'text'=>array('text', 'html'), + 'html'=>array('text', 'html'), 'password'=>array('password', 'varchar'), 'mail'=>array('varchar', 'phone', 'mail', 'url', 'select'), 'url'=>array('varchar', 'phone', 'mail', 'url', 'select'), @@ -204,12 +204,12 @@ $typewecanchangeinto=array( ); if (in_array($type, array_keys($typewecanchangeinto))) { - $newarray=array(); + $newarray = array(); print '
trans("Position"); ?>
trans("Position"); ?>
trans("LanguageFile"); ?>
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("Unique"); ?>>
trans("Unique"); ?>>
trans("Required"); ?>>
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("AlwaysEditable"); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> -
textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?>>
textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?>>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
trans("AllEntities"); ?>>
trans("AllEntities"); ?>>
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index a59350d8678..b2bb69aa0bf 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -25,7 +25,7 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; @@ -66,7 +66,7 @@ print ''.$langs->trans("AlwaysEditable").''; print ''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''; print ''.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).''; print ''.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).''; -if ($conf->multicompany->enabled){ +if ($conf->multicompany->enabled) { print ''.$langs->trans("Entities").''; } print ' '; @@ -74,16 +74,16 @@ print "\n"; if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) { - foreach($extrafields->attributes[$elementtype]['type'] as $key => $value) + foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) { // Load language if required - if (! empty($extrafields->attributes[$elementtype]['langfile'][$key])) { + if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) { $langs->load($extrafields->attributes[$elementtype]['langfile'][$key]); } print ''; print "".$extrafields->attributes[$elementtype]['pos'][$key]."\n"; - print "".$extrafields->attributes[$elementtype]['label'][$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value + print "".$extrafields->attributes[$elementtype]['label'][$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value print "".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."\n"; print "".$key."\n"; print "".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."\n"; @@ -95,7 +95,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel print ''.$extrafields->attributes[$elementtype]['list'][$key]."\n"; print ''.$extrafields->attributes[$elementtype]['printable'][$key]."\n"; print ''.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."\n"; - if (! empty($conf->multicompany->enabled)) { + if (!empty($conf->multicompany->enabled)) { print ''; if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) { @@ -103,7 +103,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel } else { global $multicompanylabel_cache; - if (! is_array($multicompanylabel_cache)) $multicompanylabel_cache = array(); + if (!is_array($multicompanylabel_cache)) $multicompanylabel_cache = array(); if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) { global $mc; $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]); @@ -120,8 +120,8 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel } else { - $colspan=13; - if (! empty($conf->multicompany->enabled)) $colspan++; + $colspan = 13; + if (!empty($conf->multicompany->enabled)) $colspan++; print ''; print ''; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e6de4520ba4..eca100731ac 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -128,10 +128,10 @@ if ($permission)
select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); + $nbofcontacts = $form->select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); $newcardbutton = ''; - if (! empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) + if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) { $newcardbutton .= ''; } @@ -140,13 +140,13 @@ if ($permission)
element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; + $tmpobject = $object; + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; $formcompany->selectTypeContact($tmpobject, '', 'type', 'external', 'position', 0, 'minwidth100imp'); ?>
 
- "> + ">
@@ -162,11 +162,11 @@ print "
"; // TODO: replace this with direct SQL string to use $db->sort($sortfield, $sortorder) $list = array(); -foreach(array('internal', 'external') as $source) +foreach (array('internal', 'external') as $source) { $tmpobject = $object; - if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { $tmpobject = $objectsrc; } @@ -200,27 +200,27 @@ foreach(array('internal', 'external') as $source) { $entry->thirdparty = $conf->global->MAIN_INFO_SOCIETE_NOM; } - elseif (! $tab[$i]['socid']) + elseif (!$tab[$i]['socid']) { $entry->thirdparty = ""; } - if ($tab[$i]['source']=='internal') + if ($tab[$i]['source'] == 'internal') { $userstatic->fetch($tab[$i]['id']); $entry->contact = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); } - elseif ($tab[$i]['source']=='external') + elseif ($tab[$i]['source'] == 'external') { $contactstatic->fetch($tab[$i]['id']); - $entry->contact =$contactstatic->getNomUrl(1, '', 0, '', 0, 0); + $entry->contact = $contactstatic->getNomUrl(1, '', 0, '', 0, 0); } - if ($tab[$i]['source']=='internal') + if ($tab[$i]['source'] == 'internal') { $entry->status = $userstatic->LibStatut($tab[$i]['statuscontact'], 3); } - elseif ($tab[$i]['source']=='external') + elseif ($tab[$i]['source'] == 'external') { $entry->status = $contactstatic->LibStatut($tab[$i]['statuscontact'], 3); } @@ -279,7 +279,7 @@ print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], " print_liste_field_titre($arrayfields['link']['label'], $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch '); print ""; -foreach($list as $entry) +foreach ($list as $entry) { print ''; @@ -314,8 +314,8 @@ print ""; print "\n"; if (is_object($hookmanager)) { $hookmanager->initHooks(array('contacttpl')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); + $parameters = array(); + $reshook = $hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); } print "\n"; diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 2ef606afa0b..45ca9a29197 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -37,14 +37,14 @@ if (empty($conf) || !is_object($conf)) executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; - $params['cols']=$parameters['colspanvalue']; + $params['cols'] = $parameters['colspanvalue']; print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params } diff --git a/htdocs/core/tpl/extrafields_edit.tpl.php b/htdocs/core/tpl/extrafields_edit.tpl.php index 8a04aa32dea..dbc2b9745cd 100644 --- a/htdocs/core/tpl/extrafields_edit.tpl.php +++ b/htdocs/core/tpl/extrafields_edit.tpl.php @@ -26,7 +26,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -37,12 +37,12 @@ if (empty($conf) || ! is_object($conf)) executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - $params=array(); - $params['cols']=$parameters['colspanvalue']; + $params = array(); + $params['cols'] = $parameters['colspanvalue']; print $object->showOptionals($extrafields, 'edit', $params); } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 510bb888813..5fc268013c6 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -378,7 +378,7 @@ if ($nolinesbefore) { "> global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; print $form->selectUnits($line->fk_unit, "units"); @@ -636,7 +636,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { console.log("We are in a price per qty context, we do not call ajax/product"); } else { - global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?> + global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?> if (isNaN(pbq)) { console.log("We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we are not yet able to get the id of pbq from product combo list, so load of price may be 0 if product has differet prices"); } // Get the HT price for the product and display it diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 66e1b6fa4cd..7acd977e714 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -59,13 +59,13 @@ class InterfaceLogevents extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) + if (!empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) - $key='MAIN_LOGEVENTS_'.$action; + $key = 'MAIN_LOGEVENTS_'.$action; //dol_syslog("xxxxxxxxxxx".$key); - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action + if (empty($conf->global->$key)) return 0; // Log events not enabled for this action - if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) + if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) $date = dol_now(); @@ -76,18 +76,18 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text="(UserLogged,".$object->login.")"; - $text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg); - $desc="(UserLogged,".$object->login.")"; - $desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg); + $text = "(UserLogged,".$object->login.")"; + $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); + $desc = "(UserLogged,".$object->login.")"; + $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); } if ($action == 'USER_LOGIN_FAILED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Initialisation donnees (date,duree,texte,desc) - $text=$object->trigger_mesg; // Message direct - $desc=$object->trigger_mesg; // Message direct + $text = $object->trigger_mesg; // Message direct + $desc = $object->trigger_mesg; // Message direct } if ($action == 'USER_LOGOUT') { @@ -95,8 +95,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text="(UserLogoff,".$object->login.")"; - $desc="(UserLogoff,".$object->login.")"; + $text = "(UserLogoff,".$object->login.")"; + $desc = "(UserLogoff,".$object->login.")"; } if ($action == 'USER_CREATE') { @@ -104,8 +104,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("NewUserCreated", $object->login); - $desc=$langs->transnoentities("NewUserCreated", $object->login); + $text = $langs->transnoentities("NewUserCreated", $object->login); + $desc = $langs->transnoentities("NewUserCreated", $object->login); } elseif ($action == 'USER_MODIFY') { @@ -113,8 +113,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("EventUserModified", $object->login); - $desc=$langs->transnoentities("EventUserModified", $object->login); + $text = $langs->transnoentities("EventUserModified", $object->login); + $desc = $langs->transnoentities("EventUserModified", $object->login); } elseif ($action == 'USER_NEW_PASSWORD') { @@ -122,8 +122,8 @@ class InterfaceLogevents extends DolibarrTriggers $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("NewUserPassword", $object->login); - $desc=$langs->transnoentities("NewUserPassword", $object->login); + $text = $langs->transnoentities("NewUserPassword", $object->login); + $desc = $langs->transnoentities("NewUserPassword", $object->login); } elseif ($action == 'USER_ENABLEDISABLE') { @@ -132,13 +132,13 @@ class InterfaceLogevents extends DolibarrTriggers // Initialisation donnees (date,duree,texte,desc) if ($object->statut == 0) { - $text=$langs->transnoentities("UserEnabled", $object->login); - $desc=$langs->transnoentities("UserEnabled", $object->login); + $text = $langs->transnoentities("UserEnabled", $object->login); + $desc = $langs->transnoentities("UserEnabled", $object->login); } if ($object->statut == 1) { - $text=$langs->transnoentities("UserDisabled", $object->login); - $desc=$langs->transnoentities("UserDisabled", $object->login); + $text = $langs->transnoentities("UserDisabled", $object->login); + $desc = $langs->transnoentities("UserDisabled", $object->login); } } elseif ($action == 'USER_DELETE') @@ -146,8 +146,8 @@ class InterfaceLogevents extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("UserDeleted", $object->login); - $desc=$langs->transnoentities("UserDeleted", $object->login); + $text = $langs->transnoentities("UserDeleted", $object->login); + $desc = $langs->transnoentities("UserDeleted", $object->login); } // Groupes @@ -156,24 +156,24 @@ class InterfaceLogevents extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("NewGroupCreated", $object->name); - $desc=$langs->transnoentities("NewGroupCreated", $object->name); + $text = $langs->transnoentities("NewGroupCreated", $object->name); + $desc = $langs->transnoentities("NewGroupCreated", $object->name); } elseif ($action == 'GROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("GroupModified", $object->name); - $desc=$langs->transnoentities("GroupModified", $object->name); + $text = $langs->transnoentities("GroupModified", $object->name); + $desc = $langs->transnoentities("GroupModified", $object->name); } elseif ($action == 'GROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - $text=$langs->transnoentities("GroupDeleted", $object->name); - $desc=$langs->transnoentities("GroupDeleted", $object->name); + $text = $langs->transnoentities("GroupDeleted", $object->name); + $desc = $langs->transnoentities("GroupDeleted", $object->name); } // If not found @@ -186,28 +186,28 @@ class InterfaceLogevents extends DolibarrTriggers */ // Add more information into desc from the context property - if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; + if (!empty($desc) && !empty($object->context['audit'])) $desc .= ' - '.$object->context['audit']; // Add entry in event table include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; - $event=new Events($this->db); - $event->type=$action; - $event->dateevent=$date; - $event->label=$text; - $event->description=$desc; - $event->user_agent=$_SERVER["HTTP_USER_AGENT"]; + $event = new Events($this->db); + $event->type = $action; + $event->dateevent = $date; + $event->label = $text; + $event->description = $desc; + $event->user_agent = $_SERVER["HTTP_USER_AGENT"]; - $result=$event->create($user); + $result = $event->create($user); if ($result > 0) { return 1; } else { - $error ="Failed to insert security event: ".$event->error; + $error = "Failed to insert security event: ".$event->error; $this->errors[] = $error; - $this->error=$error; + $this->error = $error; dol_syslog(get_class($this).": ".$error, LOG_ERR); return -1; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 161ebe6cd73..3fe9d63c380 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -71,7 +71,7 @@ class InterfaceActionsAuto extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing + if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action; @@ -82,25 +82,25 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("agenda"); - if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; + if (empty($object->actiontypecode)) $object->actiontypecode = 'AC_OTH_AUTO'; // Actions if ($action == 'COMPANY_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","companies")); + $langs->loadLangs(array("agenda", "other", "companies")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr", $object->name); - $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr", $object->name); - if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + if (!empty($object->prefix)) $object->actionmsg .= " (".$object->prefix.")"; - $object->sendtoid=0; - $object->socid=$object->id; + $object->sendtoid = 0; + $object->socid = $object->id; } elseif ($action == 'COMPANY_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); @@ -110,22 +110,22 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'CONTRACT_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","contracts")); + $langs->loadLangs(array("agenda", "other", "contracts")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'CONTRACT_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","contracts")); + $langs->loadLangs(array("agenda", "other", "contracts")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ContractSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -134,22 +134,22 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPAL_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPAL_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -158,82 +158,82 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPAL_CLOSE_SIGNED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","orders")); + $langs->loadLangs(array("agenda", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_CLOSE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_CANCEL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("OrderSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -242,32 +242,32 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_UNVALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -276,69 +276,69 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_PAYED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); // Values for this action can't be defined by caller. - $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_CANCEL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'FICHINTER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'FICHINTER_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'FICHINTER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("InterventionSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -347,44 +347,44 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'FICHINTER_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'FICHINTER_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","interventions")); + $langs->loadLangs(array("agenda", "other", "interventions")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); - $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; + $object->sendtoid = 0; + $object->fk_element = 0; + $object->elementtype = ''; } elseif ($action == 'SHIPPING_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","sendings")); + $langs->loadLangs(array("agenda", "other", "sendings")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ShippingValidated", ($object->newref?$object->newref:$object->ref)); + $object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); } // Parameters $object->sendtoid defined by caller @@ -393,12 +393,12 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'SHIPPING_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","sendings")); + $langs->loadLangs(array("agenda", "other", "sendings")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ShippingSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -409,10 +409,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("receptions"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ReceptionValidated", ($object->newref?$object->newref:$object->ref)); + $object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); } // Parameters $object->sendtoid defined by caller @@ -424,10 +424,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("receptions"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -436,22 +436,22 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -460,92 +460,92 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","propal")); + $langs->loadLangs(array("agenda", "other", "propal")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","orders")); + $langs->loadLangs(array("agenda", "other", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills","orders")); + $langs->loadLangs(array("agenda", "other", "bills", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -554,45 +554,45 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills","orders")); + $langs->loadLangs(array("agenda", "other", "bills", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); + $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); } - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills","orders")); + $langs->loadLangs(array("agenda", "other", "bills", "orders")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); if (empty($object->actionmsg)) { - $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); + $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller @@ -601,244 +601,244 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_SUPPLIER_PAYED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills")); + $langs->loadLangs(array("agenda", "other", "bills")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } // Members elseif ($action == 'MEMBER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'MEMBER_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); $member = $this->context['member']; - if (! is_object($member)) // This should not happen + if (!is_object($member)) // This should not happen { include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $member = new Adherent($this->db); $member->fetch($this->fk_adherent); } - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); - $object->sendtoid=0; - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + $object->sendtoid = 0; + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); $member = $this->context['member']; - if (! is_object($member)) // This should not happen + if (!is_object($member)) // This should not happen { include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $member = new Adherent($this->db); $member->fetch($this->fk_adherent); } - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); - $object->sendtoid=0; - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + $object->sendtoid = 0; + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); - $object->sendtoid=0; - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + $object->sendtoid = 0; + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; } elseif ($action == 'MEMBER_RESILIATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } elseif ($action == 'MEMBER_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","members")); + $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; - $object->sendtoid=0; + $object->sendtoid = 0; } // Projects elseif ($action == 'PROJECT_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'PROJECT_VALIDATE') + elseif ($action == 'PROJECT_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'PROJECT_MODIFY') + elseif ($action == 'PROJECT_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } // Project tasks - elseif($action == 'TASK_CREATE') + elseif ($action == 'TASK_CREATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'TASK_MODIFY') + elseif ($action == 'TASK_MODIFY') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'TASK_DELETE') + elseif ($action == 'TASK_DELETE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr", $object->ref); - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; - $object->sendtoid=0; + $object->sendtoid = 0; } - elseif($action == 'TICKET_ASSIGNED') + elseif ($action == 'TICKET_ASSIGNED') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","projects")); + $langs->loadLangs(array("agenda", "other", "projects")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); - $object->actionmsg=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); + $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); if ($object->oldcopy->fk_user_assign > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($object->oldcopy->fk_user_assign); - $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs); } else { - $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$langs->trans("None"); + $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$langs->trans("None"); } if ($object->fk_user_assign > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($object->fk_user_assign); - $object->actionmsg.="\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs); } else { - $object->actionmsg.="\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); + $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); } - $object->sendtoid=0; + $object->sendtoid = 0; } // TODO Merge all previous cases into this generic one else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... { // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). Key can be set in agenda setup if defined into c_action_trigger // Load translation files required by the page - $langs->loadLangs(array("agenda","other")); + $langs->loadLangs(array("agenda", "other")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr", $object->ref); - if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr", $object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", $object->ref); + if (empty($object->actionmsg)) $object->actionmsg = $langs->transnoentities($action."InDolibarr", $object->ref); - $object->sendtoid=0; + $object->sendtoid = 0; } $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg; @@ -846,21 +846,21 @@ class InterfaceActionsAuto extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Add entry in event table - $now=dol_now(); + $now = dol_now(); if (isset($_SESSION['listofnames-'.$object->trackid])) { - $attachs=$_SESSION['listofnames-'.$object->trackid]; + $attachs = $_SESSION['listofnames-'.$object->trackid]; if ($attachs && strpos($action, 'SENTBYMAIL')) { - $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); + $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); } } require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $contactforaction=new Contact($this->db); - $societeforaction=new Societe($this->db); + $contactforaction = new Contact($this->db); + $societeforaction = new Societe($this->db); // Set contactforaction if there is only 1 contact. if (is_array($object->sendtoid)) { @@ -874,7 +874,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if ($object->socid > 0) $societeforaction->fetch($object->socid); elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); - $projectid = isset($object->fk_project)?$object->fk_project:0; + $projectid = isset($object->fk_project) ? $object->fk_project : 0; if ($object->element == 'project') $projectid = $object->id; $elementid = $object->id; @@ -889,20 +889,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; - $actioncomm->note_private= $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) + $actioncomm->note_private = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->punctual = 1; - $actioncomm->percentage = -1; // Not applicable + $actioncomm->percentage = -1; // Not applicable $actioncomm->socid = $societeforaction->id; $actioncomm->contactid = $contactforaction->id; - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label) $actioncomm->email_msgid = $object->email_msgid; $actioncomm->email_from = $object->email_from; @@ -915,28 +915,28 @@ class InterfaceActionsAuto extends DolibarrTriggers // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table // for such objects because there is already a dedicated field into table llx_actioncomm. - if (! in_array($elementtype, array('societe','contact','project'))) + if (!in_array($elementtype, array('societe', 'contact', 'project'))) { $actioncomm->fk_element = $elementid; $actioncomm->elementtype = $elementtype; } - if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) { - $actioncomm->attachedfiles=$object->attachedfiles; + if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) { + $actioncomm->attachedfiles = $object->attachedfiles; } - if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) { - $actioncomm->userassigned=$object->sendtouserid; + if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid) > 0) { + $actioncomm->userassigned = $object->sendtouserid; } - $ret=$actioncomm->create($user); // User creating action + $ret = $actioncomm->create($user); // User creating action if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) { - if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths'])>0) { - foreach($object->attachedfiles['paths'] as $key=>$filespath) { + if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) { + foreach ($object->attachedfiles['paths'] as $key=>$filespath) { $srcfile = $filespath; - $destdir = $conf->agenda->dir_output . '/' . $ret; - $destfile = $destdir . '/' . $object->attachedfiles['names'][$key]; + $destdir = $conf->agenda->dir_output.'/'.$ret; + $destfile = $destdir.'/'.$object->attachedfiles['names'][$key]; if (dol_mkdir($destdir) >= 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_copy($srcfile, $destfile); @@ -945,7 +945,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } } - unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. + unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. if ($ret > 0) { @@ -954,8 +954,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } else { - $this->error="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); - $this->errors=$actioncomm->errors; + $this->error = "Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); + $this->errors = $actioncomm->errors; dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR); return -1; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 3cd49a20649..fd01809bc3b 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -27,27 +27,27 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","donations")); +$langs->loadLangs(array("companies", "donations")); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="d.datedon"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.datedon"; -$search_status=(GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4"; -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_name=GETPOST('search_name', 'alpha'); +$search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4"; +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_name = GETPOST('search_name', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -79,26 +79,26 @@ $fieldstosearchall = array( * View */ -$form=new Form($db); -if (! empty($conf->projet->enabled)) $projectstatic=new Project($db); +$form = new Form($db); +if (!empty($conf->projet->enabled)) $projectstatic = new Project($db); llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'); -$donationstatic=new Don($db); +$donationstatic = new Don($db); // Genere requete de liste des dons $sql = "SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,"; -$sql.= " d.amount, d.fk_statut as status,"; -$sql.= " p.rowid as pid, p.ref, p.title, p.public"; -$sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; -$sql.= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; +$sql .= " d.amount, d.fk_statut as status,"; +$sql .= " p.rowid as pid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; +$sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; if ($search_status != '' && $search_status != '-4') { $sql .= " AND d.fk_statut IN (".$db->escape($search_status).")"; } if (trim($search_ref) != '') { - $sql.= natural_search('d.ref', $search_ref); + $sql .= natural_search('d.ref', $search_ref); } if (trim($search_all) != '') { @@ -137,17 +137,17 @@ if ($resql) $i = 0; $param = ''; - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($search_status && $search_status != -1) $param .= '&search_status='.urlencode($search_status); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_company) $param .= '&search_company='.urlencode($search_company); if ($search_name) $param .= '&search_name='.urlencode($search_name); if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->don->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); } print '
'."\n"; @@ -163,19 +163,19 @@ if ($resql) if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } print '
'; - print ''."\n"; + print '
'."\n"; // Filters lines print ''; print ''; - if (! empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { print ''; @@ -207,21 +207,21 @@ if ($resql) print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); print ''; print ''; print "\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder); - if (! empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "d.fk_soc", "", $param, "", $sortfield, $sortorder); } else { print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder); @@ -236,15 +236,15 @@ if ($resql) $objp = $db->fetch_object($resql); print ''; - $donationstatic->id=$objp->rowid; - $donationstatic->ref=$objp->rowid; - $donationstatic->lastname=$objp->lastname; - $donationstatic->firstname=$objp->firstname; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; print ""; - if (! empty($conf->global->DONATION_USE_THIRDPARTIES)) { - $company=new Societe($db); - $result=$company->fetch($objp->socid); - if (!empty($objp->socid) && $company->id > 0) { + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + $company = new Societe($db); + $result = $company->fetch($objp->socid); + if (!empty($objp->socid) && $company->id > 0) { print ""; } else { print ""; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 57311c2e437..11cf2477720 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -814,7 +814,7 @@ class EmailCollector extends CommonObject { //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty - $object->$tmpproperty = isset($regforval[count($regforval)-1]) ?trim($regforval[count($regforval)-1]) : null; + $object->$tmpproperty = isset($regforval[count($regforval) - 1]) ?trim($regforval[count($regforval) - 1]) : null; } else { @@ -1135,7 +1135,7 @@ class EmailCollector extends CommonObject if (function_exists('imap_mime_header_decode')) { $elements = imap_mime_header_decode($overview[0]->subject); $newstring = ''; - if (! empty($elements)) { + if (!empty($elements)) { $num = count($elements); for ($i = 0; $i < $num; $i++) { $newstring .= ($newstring ? ' ' : '').$elements[$i]->text; @@ -1426,7 +1426,7 @@ class EmailCollector extends CommonObject { //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty - $nametouseforthirdparty = isset($regforval[count($regforval)-1]) ?trim($regforval[count($regforval)-1]) : null; + $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ?trim($regforval[count($regforval) - 1]) : null; } else { @@ -1796,10 +1796,10 @@ class EmailCollector extends CommonObject } // Create event specific on hook // this code action is hook..... for support this call - elseif (substr($operation['type'], 0, 4) == 'hook'){ + elseif (substr($operation['type'], 0, 4) == 'hook') { global $hookmanager; - if(!is_object($hookmanager)) + if (!is_object($hookmanager)) $hookmanager->initHooks(array('emailcollectorcard')); $parameters = array( @@ -1807,24 +1807,24 @@ class EmailCollector extends CommonObject 'imapemail'=>$imapemail, 'overview'=>$overview, - 'from' => $from , + 'from' => $from, 'fromtext' => $fromtext, 'actionparam'=> $operation['actionparam'], - 'thirdpartyid' => $thirdpartyid , + 'thirdpartyid' => $thirdpartyid, 'objectid'=> $objectid, 'objectemail'=> $objectemail, 'messagetext'=>$messagetext, 'subject'=>$subject, 'header'=>$header, - ) ; + ); $res = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); - if($res < 0 ) + if ($res < 0) $this->error = $hookmanager->resPrint; } @@ -2047,7 +2047,7 @@ class EmailCollector extends CommonObject // TEXT if ($p->type == 0 && $data) { - if(!empty($params['charset'])) { + if (!empty($params['charset'])) { $data = $this->convertStringEncoding($data, $params['charset']); } // Messages may be split in different parts because of inline attachments, @@ -2065,7 +2065,7 @@ class EmailCollector extends CommonObject // There are no PHP functions to parse embedded messages, // so this just appends the raw source to the main message. elseif ($p->type == 2 && $data) { - if(!empty($params['charset'])) { + if (!empty($params['charset'])) { $data = $this->convertStringEncoding($data, $params['charset']); } $plainmsg .= $data."\n\n"; @@ -2091,14 +2091,14 @@ class EmailCollector extends CommonObject */ protected function convertStringEncoding($string, $fromEncoding, $toEncoding = 'UTF-8') { - if(!$string || $fromEncoding == $toEncoding) { + if (!$string || $fromEncoding == $toEncoding) { return $string; } - $convertedString = function_exists('iconv') ? @iconv($fromEncoding, $toEncoding . '//IGNORE', $string) : null; - if(!$convertedString && extension_loaded('mbstring')) { + $convertedString = function_exists('iconv') ? @iconv($fromEncoding, $toEncoding.'//IGNORE', $string) : null; + if (!$convertedString && extension_loaded('mbstring')) { $convertedString = @mb_convert_encoding($string, $toEncoding, $fromEncoding); } - if(!$convertedString) { + if (!$convertedString) { throw new Exception('Mime string encoding conversion failed'); } return $convertedString; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4c6b7f46e47..52540901c33 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -287,90 +287,90 @@ class Expedition extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition ("; - $sql.= "ref"; - $sql.= ", entity"; - $sql.= ", ref_customer"; - $sql.= ", ref_int"; - $sql.= ", date_creation"; - $sql.= ", fk_user_author"; - $sql.= ", date_expedition"; - $sql.= ", date_delivery"; - $sql.= ", fk_soc"; - $sql.= ", fk_projet"; - $sql.= ", fk_address"; - $sql.= ", fk_shipping_method"; - $sql.= ", tracking_number"; - $sql.= ", weight"; - $sql.= ", size"; - $sql.= ", width"; - $sql.= ", height"; - $sql.= ", weight_units"; - $sql.= ", size_units"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", model_pdf"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ") VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".($this->ref_customer?"'".$this->db->escape($this->ref_customer)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null"); - $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); - $sql.= ", ".$this->socid; - $sql.= ", ".$this->fk_project; - $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); - $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); - $sql.= ", '".$this->db->escape($this->tracking_number)."'"; - $sql.= ", ".$this->weight; - $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth - $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth - $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); - $sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); - $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"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.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ")"; + $sql .= "ref"; + $sql .= ", entity"; + $sql .= ", ref_customer"; + $sql .= ", ref_int"; + $sql .= ", date_creation"; + $sql .= ", fk_user_author"; + $sql .= ", date_expedition"; + $sql .= ", date_delivery"; + $sql .= ", fk_soc"; + $sql .= ", fk_projet"; + $sql .= ", fk_address"; + $sql .= ", fk_shipping_method"; + $sql .= ", tracking_number"; + $sql .= ", weight"; + $sql .= ", size"; + $sql .= ", width"; + $sql .= ", height"; + $sql .= ", weight_units"; + $sql .= ", size_units"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", model_pdf"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ") VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".($this->ref_customer ? "'".$this->db->escape($this->ref_customer)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_expedition > 0 ? "'".$this->db->idate($this->date_expedition)."'" : "null"); + $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); + $sql .= ", ".$this->socid; + $sql .= ", ".$this->fk_project; + $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); + $sql .= ", '".$this->db->escape($this->tracking_number)."'"; + $sql .= ", ".$this->weight; + $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth + $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth + $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight + $sql .= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); + $sql .= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); + $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "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 .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; - $sql.= " SET ref = '(PROV".$this->id.")'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '(PROV".$this->id.")'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { // Insert of lines - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { - if (! isset($this->lines[$i]->detail_batch)) + if (!isset($this->lines[$i]->detail_batch)) { // no batch management - if (! $this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) > 0) + if (!$this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) > 0) { $error++; } } else { // with batch management - if (! $this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) > 0) + if (!$this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) > 0) { $error++; } } } - if (! $error && $this->id && $this->origin_id) + if (!$error && $this->id && $this->origin_id) { $ret = $this->add_object_linked(); if (!$ret) @@ -535,24 +535,24 @@ class Expedition extends CommonObject if (empty($id) && empty($ref) && empty($ref_ext)) return -1; $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed"; - $sql.= ", e.date_valid"; - $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; - $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; - $sql.= ", e.fk_shipping_method, e.tracking_number"; - $sql.= ", e.note_private, e.note_public"; - $sql.= ', e.fk_incoterms, e.location_incoterms'; - $sql.= ', i.libelle as label_incoterms'; - $sql.= ', s.libelle as shipping_method'; - $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as s ON e.fk_shipping_method = s.rowid'; - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; - if ($id) $sql.= " AND e.rowid=".$id; - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($notused) $sql.= " AND e.ref_int='".$this->db->escape($notused)."'"; + $sql .= ", e.date_valid"; + $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; + $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; + $sql .= ", e.fk_shipping_method, e.tracking_number"; + $sql .= ", e.note_private, e.note_public"; + $sql .= ', e.fk_incoterms, e.location_incoterms'; + $sql .= ', i.libelle as label_incoterms'; + $sql .= ', s.libelle as shipping_method'; + $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as s ON e.fk_shipping_method = s.rowid'; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + if ($id) $sql .= " AND e.rowid=".$id; + if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($notused) $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -565,26 +565,26 @@ class Expedition extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; - $this->ref_customer = $obj->ref_customer; + $this->ref_customer = $obj->ref_customer; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_valid = $this->db->jdate($obj->date_valid); - $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated - $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated - $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real - $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed + $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated + $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated + $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real + $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; $this->shipping_method_id = $obj->fk_shipping_method; - $this->shipping_method = $obj->shipping_method; + $this->shipping_method = $obj->shipping_method; $this->tracking_number = $obj->tracking_number; - $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility + $this->origin = ($obj->origin ? $obj->origin : 'commande'); // For compatibility $this->origin_id = $obj->origin_id; $this->billed = $obj->billed; - $this->fk_project = $obj->fk_project; + $this->fk_project = $obj->fk_project; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; @@ -763,7 +763,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref)); if ($result < 0) { $error++; $this->error = $mouvS->error; @@ -777,7 +777,7 @@ class Expedition extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $error++; $this->error = $mouvS->error; @@ -819,17 +819,17 @@ class Expedition extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/sending/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expedition/sending/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->expedition->dir_output.'/sending/'.$oldref; $dirdest = $conf->expedition->dir_output.'/sending/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); @@ -852,13 +852,13 @@ class Expedition extends CommonObject } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $numref; $this->statut = self::STATUS_VALIDATED; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -866,7 +866,7 @@ class Expedition extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -1173,32 +1173,32 @@ class Expedition extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - $error=0; - $this->error=''; + $error = 0; + $this->error = ''; $this->db->begin(); // Add a protection to refuse deleting if shipment has at least one delivery - $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment + $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment if (count($this->linkedObjectsIds) > 0) { - $this->error='ErrorThereIsSomeDeliveries'; + $this->error = 'ErrorThereIsSomeDeliveries'; $error++; } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_DELETE', $user); + $result = $this->call_trigger('SHIPPING_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } } // Stock control - if (! $error && $conf->stock->enabled && + if (!$error && $conf->stock->enabled && (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { @@ -1387,20 +1387,20 @@ class Expedition extends CommonObject // phpcs:enable global $conf, $mysoc; // TODO: recuperer les champs du document associe a part - $this->lines=array(); + $this->lines = array(); $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; - $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; - $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; - $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang"; - $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; - $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; - $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND ed.fk_origin_line = cd.rowid"; - $sql.= " ORDER BY cd.rang, ed.fk_origin_line"; + $sql .= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; + $sql .= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql .= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang"; + $sql .= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; + $sql .= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; + $sql .= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; + $sql .= " WHERE ed.fk_expedition = ".$this->id; + $sql .= " AND ed.fk_origin_line = cd.rowid"; + $sql .= " ORDER BY cd.rang, ed.fk_origin_line"; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1461,7 +1461,7 @@ class Expedition extends CommonObject $line->label = $obj->custom_label; $line->description = $obj->description; $line->qty_asked = $obj->qty_asked; - $line->rang = $obj->rang; + $line->rang = $obj->rang; $line->weight = $obj->weight; $line->weight_units = $obj->weight_units; $line->length = $obj->length; @@ -1750,23 +1750,23 @@ class Expedition extends CommonObject $this->origin_id = 1; $this->origin = 'commande'; - $this->note_private = 'Private note'; - $this->note_public = 'Public note'; + $this->note_private = 'Private note'; + $this->note_public = 'Public note'; $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $line=new ExpeditionLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->libelle=$langs->trans("Description")." ".$xnbp; // deprecated - $line->label=$langs->trans("Description")." ".$xnbp; - $line->qty=10; - $line->qty_asked=5; - $line->qty_shipped=4; - $line->fk_product=$this->commande->lines[$xnbp]->fk_product; + $line = new ExpeditionLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->libelle = $langs->trans("Description")." ".$xnbp; // deprecated + $line->label = $langs->trans("Description")." ".$xnbp; + $line->qty = 10; + $line->qty_asked = 5; + $line->qty_shipped = 4; + $line->fk_product = $this->commande->lines[$xnbp]->fk_product; - $this->lines[]=$line; + $this->lines[] = $line; $xnbp++; } } @@ -1820,17 +1820,17 @@ class Expedition extends CommonObject $this->meths = array(); $sql = "SELECT em.rowid, em.code, em.libelle as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.active = 1"; - $sql.= " ORDER BY em.libelle ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.active = 1"; + $sql .= " ORDER BY em.libelle ASC"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { - $label=$langs->trans('SendingMethod'.$obj->code); - $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code?$label:$obj->label); + $label = $langs->trans('SendingMethod'.$obj->code); + $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code ? $label : $obj->label); } } } @@ -1848,11 +1848,11 @@ class Expedition extends CommonObject global $langs; $this->listmeths = array(); - $i=0; + $i = 0; $sql = "SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - if ($id!='') $sql.= " WHERE em.rowid=".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + if ($id != '') $sql .= " WHERE em.rowid=".$id; $resql = $this->db->query($sql); if ($resql) @@ -1861,8 +1861,8 @@ class Expedition extends CommonObject { $this->listmeths[$i]['rowid'] = $obj->rowid; $this->listmeths[$i]['code'] = $obj->code; - $label=$langs->trans('SendingMethod'.$obj->code); - $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->label); + $label = $langs->trans('SendingMethod'.$obj->code); + $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code ? $label : $obj->label); $this->listmeths[$i]['description'] = $obj->description; $this->listmeths[$i]['tracking'] = $obj->tracking; $this->listmeths[$i]['active'] = $obj->active; @@ -2316,16 +2316,16 @@ class Expedition extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("sendings"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'rouget'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->EXPEDITION_ADDON_PDF)) { + } elseif (!empty($conf->global->EXPEDITION_ADDON_PDF)) { $modele = $conf->global->EXPEDITION_ADDON_PDF; } } @@ -2567,10 +2567,10 @@ class ExpeditionLigne extends CommonObjectLine { global $langs, $conf; - $error=0; + $error = 0; // Check parameters - if (empty($this->fk_expedition) || empty($this->fk_origin_line) || ! is_numeric($this->qty)) + if (empty($this->fk_expedition) || empty($this->fk_origin_line) || !is_numeric($this->qty)) { $this->error = 'ErrorMandatoryParametersNotProvided'; return -1; @@ -2589,18 +2589,18 @@ class ExpeditionLigne extends CommonObjectLine } $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; - $sql.= "fk_expedition"; - $sql.= ", fk_entrepot"; - $sql.= ", fk_origin_line"; - $sql.= ", qty"; - $sql.= ", rang"; - $sql.= ") VALUES ("; - $sql.= $this->fk_expedition; - $sql.= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id); - $sql.= ", ".$this->fk_origin_line; - $sql.= ", ".$this->qty; - $sql.= ", ".$ranktouse; - $sql.= ")"; + $sql .= "fk_expedition"; + $sql .= ", fk_entrepot"; + $sql .= ", fk_origin_line"; + $sql .= ", qty"; + $sql .= ", rang"; + $sql .= ") VALUES ("; + $sql .= $this->fk_expedition; + $sql .= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id); + $sql .= ", ".$this->fk_origin_line; + $sql .= ", ".$this->qty; + $sql .= ", ".$ranktouse; + $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 15073c50620..872bd5a0792 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -31,14 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'banks', 'trips')); -$id=GETPOST("id", 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'aZ09'); +$id = GETPOST("id", 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); $amounts = array(); -$accountid=GETPOST('accountid', 'int'); +$accountid = GETPOST('accountid', 'int'); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) { $socid = $user->socid; @@ -51,7 +51,7 @@ if ($user->socid > 0) if ($action == 'add_payment') { - $error=0; + $error = 0; if ($_POST["cancel"]) { @@ -62,7 +62,7 @@ if ($action == 'add_payment') $expensereport = new ExpenseReport($db); $result = $expensereport->fetch($id, $ref); - if (! $result) + if (!$result) { $error++; setEventMessages($expensereport->error, $expensereport->errors, 'errors'); @@ -70,7 +70,7 @@ if ($action == 'add_payment') $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! ($_POST["fk_typepayment"] > 0)) + if (!($_POST["fk_typepayment"] > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; @@ -80,13 +80,13 @@ if ($action == 'add_payment') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled) && ! ($accountid > 0)) + if (!empty($conf->banque->enabled) && !($accountid > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $paymentid = 0; $total = 0; @@ -104,10 +104,10 @@ if ($action == 'add_payment') if (count($amounts) <= 0) { $error++; - $errmsg='ErrorNoPaymentDefined'; + $errmsg = 'ErrorNoPaymentDefined'; } - if (! $error) + if (!$error) { $db->begin(); @@ -115,13 +115,13 @@ if ($action == 'add_payment') $payment = new PaymentExpenseReport($db); $payment->fk_expensereport = $expensereport->id; $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant + $payment->amounts = $amounts; // Tableau de montant $payment->total = $total; $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); $payment->note_public = GETPOST("note_public", 'none'); - if (! $error) + if (!$error) { $paymentid = $payment->create($user); if ($paymentid < 0) @@ -131,10 +131,10 @@ if ($action == 'add_payment') } } - if (! $error) + if (!$error) { - $result=$payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); - if (! $result > 0) + $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); + if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; @@ -152,7 +152,7 @@ if ($action == 'add_payment') } } - if (! $error) + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; @@ -166,7 +166,7 @@ if ($action == 'add_payment') } } - $action='create'; + $action = 'create'; } @@ -176,7 +176,7 @@ if ($action == 'add_payment') llxHeader(); -$form=new Form($db); +$form = new Form($db); // Form to create expense report payment @@ -188,7 +188,7 @@ if ($action == 'create' || empty($action)) $total = $expensereport->total_ttc; // autofill remainder amount - if (! empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; + print ''."\n"; } // jQuery jeditable From f07d228537262c421e47a715d2539c7381eabf2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 02:28:01 +0100 Subject: [PATCH 055/833] Upgrade mobiledetect from 2.8.33 to 2.8.34 --- COPYRIGHT | 2 +- composer.json | 6 +- composer.lock | 12 ++-- .../mobiledetectlib/Mobile_Detect.json | 2 +- .../mobiledetectlib/Mobile_Detect.php | 32 +++++---- .../mobiledetect/mobiledetectlib/README.md | 6 +- .../mobiledetectlib/composer.json | 71 +++++++++++-------- .../mobiledetectlib/docker-compose.yml | 16 +++++ .../mobiledetectlib/docs/KNOWN_LIMITATIONS.md | 3 +- 9 files changed, 91 insertions(+), 59 deletions(-) create mode 100644 htdocs/includes/mobiledetect/mobiledetectlib/docker-compose.yml diff --git a/COPYRIGHT b/COPYRIGHT index 09557f6520e..1df1167fd5d 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -17,7 +17,7 @@ CKEditor 4.12.1 LGPL-2.1+ Yes EvalMath 1.0 BSD Yes Safe math expressions evaluation Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package) -Mobiledetect 2.8.33 MIT License Yes Detect mobile devices browsers +Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency ParseDown 1.6 MIT License Yes Markdown parser diff --git a/composer.json b/composer.json index 358b7b05880..c61f985c5bf 100644 --- a/composer.json +++ b/composer.json @@ -28,11 +28,11 @@ "ext-curl" : "*", "ckeditor/ckeditor" : "4.12.1", "mike42/escpos-php" : "2.2", - "mobiledetect/mobiledetectlib" : "2.8.33", + "mobiledetect/mobiledetectlib" : "2.8.34", "phpoffice/phpexcel" : "1.8.1", "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", - "nnnick/chartjs": "2.9.3" + "nnnick/chartjs" : "2.9.3" }, "require-dev" : { "jakub-onderka/php-parallel-lint" : "^0", @@ -56,4 +56,4 @@ "ext-zip" : "ODT, Excel and file compression support", "ext-xml" : "Excel support" } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index edf324994a1..93a6a621e56 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "9f3a6e33d25fad5f44426d0dc8fc3c3d", + "content-hash": "3c03efa3fe59b85d3d389e01cc65812b", "packages": [ { "name": "ckeditor/ckeditor", @@ -104,16 +104,16 @@ }, { "name": "mobiledetect/mobiledetectlib", - "version": "2.8.33", + "version": "2.8.34", "source": { "type": "git", "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "cd385290f9a0d609d2eddd165a1e44ec1bf12102" + "reference": "6f8113f57a508494ca36acbcfa2dc2d923c7ed5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/cd385290f9a0d609d2eddd165a1e44ec1bf12102", - "reference": "cd385290f9a0d609d2eddd165a1e44ec1bf12102", + "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/6f8113f57a508494ca36acbcfa2dc2d923c7ed5b", + "reference": "6f8113f57a508494ca36acbcfa2dc2d923c7ed5b", "shasum": "" }, "require": { @@ -152,7 +152,7 @@ "mobile detector", "php mobile detect" ], - "time": "2018-09-01T15:05:15+00:00" + "time": "2019-09-18T18:44:20+00:00" }, { "name": "nnnick/chartjs", diff --git a/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json b/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json index a4361a9f5e1..2b807e11557 100644 --- a/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json +++ b/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json @@ -1 +1 @@ -{"version":"2.8.33","headerMatch":{"HTTP_ACCEPT":{"matches":["application\/x-obml2d","application\/vnd.rim.html","text\/vnd.wap.wml","application\/vnd.wap.xhtml+xml"]},"HTTP_X_WAP_PROFILE":null,"HTTP_X_WAP_CLIENTID":null,"HTTP_WAP_CONNECTION":null,"HTTP_PROFILE":null,"HTTP_X_OPERAMINI_PHONE_UA":null,"HTTP_X_NOKIA_GATEWAY_ID":null,"HTTP_X_ORANGE_ID":null,"HTTP_X_VODAFONE_3GPDPCONTEXT":null,"HTTP_X_HUAWEI_USERID":null,"HTTP_UA_OS":null,"HTTP_X_MOBILE_GATEWAY":null,"HTTP_X_ATT_DEVICEID":null,"HTTP_UA_CPU":{"matches":["ARM"]}},"uaHttpHeaders":["HTTP_USER_AGENT","HTTP_X_OPERAMINI_PHONE_UA","HTTP_X_DEVICE_USER_AGENT","HTTP_X_ORIGINAL_USER_AGENT","HTTP_X_SKYFIRE_PHONE","HTTP_X_BOLT_PHONE_UA","HTTP_DEVICE_STOCK_UA","HTTP_X_UCBROWSER_DEVICE_UA"],"uaMatch":{"phones":{"iPhone":"\\biPhone\\b|\\biPod\\b","BlackBerry":"BlackBerry|\\bBB10\\b|rim[0-9]+","HTC":"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel","Nexus":"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6","Dell":"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b","Motorola":"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052","Samsung":"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F","LG":"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)","Sony":"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533","Asus":"Asus.*Galaxy|PadFone.*Mobile","NokiaLumia":"Lumia [0-9]{3,4}","Micromax":"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b","Palm":"PalmSource|Palm","Vertu":"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature","Pantech":"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790","Fly":"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250","Wiko":"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM","iMobile":"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)","SimValley":"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b","Wolfgang":"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q","Alcatel":"Alcatel","Nintendo":"Nintendo (3DS|Switch)","Amoi":"Amoi","INQ":"INQ","GenericPhone":"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},"tablets":{"iPad":"iPad|iPad.*Mobile","NexusTablet":"Android.*Nexus[\\s]+(7|9|10)","GoogleTablet":"Android.*Pixel C","SamsungTablet":"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835","Kindle":"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk\/[0-9.]+ like Chrome\/[0-9.]+ (?!Mobile)","SurfaceTablet":"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)","HPTablet":"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10","AsusTablet":"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b","BlackBerryTablet":"PlayBook|RIM Tablet","HTCtablet":"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410","MotorolaTablet":"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617","NookTablet":"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2","AcerTablet":"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30","ToshibaTablet":"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO","LGTablet":"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b","FujitsuTablet":"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b","PrestigioTablet":"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002","LenovoTablet":"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304F|TB-X304L|TB-8703F|Tab2A7-10F|TB2-X30L","DellTablet":"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7","YarvikTablet":"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b","MedionTablet":"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB","ArnovaTablet":"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2","IntensoTablet":"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004","IRUTablet":"M702pro","MegafonTablet":"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b","EbodaTablet":"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)","AllViewTablet":"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)","ArchosTablet":"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b","AinolTablet":"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark","NokiaLumiaTablet":"Lumia 2520","SonyTablet":"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712","PhilipsTablet":"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b","CubeTablet":"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT","CobyTablet":"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010","MIDTablet":"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10","MSITablet":"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b","SMiTTablet":"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)","RockChipTablet":"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A","FlyTablet":"IQ310|Fly Vision","bqTablet":"Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))|Maxwell.*Lite|Maxwell.*Plus","HuaweiTablet":"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09","NecTablet":"\\bN-06D|\\bN-08D","PantechTablet":"Pantech.*P4100","BronchoTablet":"Broncho.*(N701|N708|N802|a710)","VersusTablet":"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b","ZyncTablet":"z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900","PositivoTablet":"TB07STA|TB10STA|TB07FTA|TB10FTA","NabiTablet":"Android.*\\bNabi","KoboTablet":"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build","DanewTablet":"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b","TexetTablet":"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE","PlaystationTablet":"Playstation.*(Portable|Vita)","TrekstorTablet":"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab","PyleAudioTablet":"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b","AdvanTablet":"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ","DanyTechTablet":"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1","GalapadTablet":"Android.*\\bG1\\b(?!\\))","MicromaxTablet":"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b","KarbonnTablet":"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b","AllFineTablet":"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide","PROSCANTablet":"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b","YONESTablet":"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026","ChangJiaTablet":"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503","GUTablet":"TX-A1301|TX-M9002|Q702|kf026","PointOfViewTablet":"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10","OvermaxTablet":"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027","HCLTablet":"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync","DPSTablet":"DPS Dream 9|DPS Dual 7","VistureTablet":"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10","CrestaTablet":"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989","MediatekTablet":"\\bMT8125|MT8389|MT8135|MT8377\\b","ConcordeTablet":"Concorde([ ]+)?Tab|ConCorde ReadMan","GoCleverTablet":"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042","ModecomTablet":"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003","VoninoTablet":"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b","ECSTablet":"V07OT2|TM105A|S10OT1|TR10CS1","StorexTablet":"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab","VodafoneTablet":"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497","EssentielBTablet":"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2","RossMoorTablet":"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711","iMobileTablet":"i-mobile i-note","TolinoTablet":"tolino tab [0-9.]+|tolino shine","AudioSonicTablet":"\\bC-22Q|T7-QC|T-17B|T-17P\\b","AMPETablet":"Android.* A78 ","SkkTablet":"Android.* (SKYPAD|PHOENIX|CYCLOPS)","TecnoTablet":"TECNO P9|TECNO DP8D","JXDTablet":"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b","iJoyTablet":"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)","FX2Tablet":"FX2 PAD7|FX2 PAD10","XoroTablet":"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151","ViewsonicTablet":"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a","VerizonTablet":"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1","OdysTablet":"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10","CaptivaTablet":"CAPTIVA PAD","IconbitTablet":"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S","TeclastTablet":"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi","OndaTablet":"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b","JaytechTablet":"TPC-PA762","BlaupunktTablet":"Endeavour 800NG|Endeavour 1010","DigmaTablet":"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b","EvolioTablet":"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b","LavaTablet":"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b","AocTablet":"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712","MpmanTablet":"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010","CelkonTablet":"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b","WolderTablet":"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b","MediacomTablet":"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA","MiTablet":"\\bMI PAD\\b|\\bHM NOTE 1W\\b","NibiruTablet":"Nibiru M1|Nibiru Jupiter One","NexoTablet":"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI","LeaderTablet":"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100","UbislateTablet":"UbiSlate[\\s]?7C","PocketBookTablet":"Pocketbook","KocasoTablet":"\\b(TB-1207)\\b","HisenseTablet":"\\b(F5281|E2371)\\b","Hudl":"Hudl HT7S3|Hudl 2","TelstraTablet":"T-Hub2","GenericTablet":"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},"browsers":{"Chrome":"\\bCrMo\\b|CriOS|Android.*Chrome\/[.0-9]* (Mobile)?","Dolfin":"\\bDolfin\\b","Opera":"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+$|Coast\/[0-9.]+","Skyfire":"Skyfire","Edge":"Mobile Safari\/[.0-9]* Edge","IE":"IEMobile|MSIEMobile","Firefox":"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS","Bolt":"bolt","TeaShark":"teashark","Blazer":"Blazer","Safari":"Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari","WeChat":"\\bMicroMessenger\\b","UCBrowser":"UC.*Browser|UCWEB","baiduboxapp":"baiduboxapp","baidubrowser":"baidubrowser","DiigoBrowser":"DiigoBrowser","Puffin":"Puffin","Mercury":"\\bMercury\\b","ObigoBrowser":"Obigo","NetFront":"NF-Browser","GenericBrowser":"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger","PaleMoon":"Android.*PaleMoon|Mobile.*PaleMoon"},"os":{"AndroidOS":"Android","BlackBerryOS":"blackberry|\\bBB10\\b|rim tablet os","PalmOS":"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino","SymbianOS":"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b","WindowsMobileOS":"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;","WindowsPhoneOS":"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;","iOS":"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia","MeeGoOS":"MeeGo","MaemoOS":"Maemo","JavaOS":"J2ME\/|\\bMIDP\\b|\\bCLDC\\b","webOS":"webOS|hpwOS","badaOS":"\\bBada\\b","BREWOS":"BREW"},"utilities":{"Bot":"Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom","MobileBot":"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker\/M1A1-R2D2","DesktopMode":"WPDesktop","TV":"SonyDTV|HbbTV","WebKit":"(webkit)[ \/]([\\w.]+)","Console":"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b","Watch":"SM-V700"}}} \ No newline at end of file +{"version":"2.8.34","headerMatch":{"HTTP_ACCEPT":{"matches":["application\/x-obml2d","application\/vnd.rim.html","text\/vnd.wap.wml","application\/vnd.wap.xhtml+xml"]},"HTTP_X_WAP_PROFILE":null,"HTTP_X_WAP_CLIENTID":null,"HTTP_WAP_CONNECTION":null,"HTTP_PROFILE":null,"HTTP_X_OPERAMINI_PHONE_UA":null,"HTTP_X_NOKIA_GATEWAY_ID":null,"HTTP_X_ORANGE_ID":null,"HTTP_X_VODAFONE_3GPDPCONTEXT":null,"HTTP_X_HUAWEI_USERID":null,"HTTP_UA_OS":null,"HTTP_X_MOBILE_GATEWAY":null,"HTTP_X_ATT_DEVICEID":null,"HTTP_UA_CPU":{"matches":["ARM"]}},"uaHttpHeaders":["HTTP_USER_AGENT","HTTP_X_OPERAMINI_PHONE_UA","HTTP_X_DEVICE_USER_AGENT","HTTP_X_ORIGINAL_USER_AGENT","HTTP_X_SKYFIRE_PHONE","HTTP_X_BOLT_PHONE_UA","HTTP_DEVICE_STOCK_UA","HTTP_X_UCBROWSER_DEVICE_UA"],"uaMatch":{"phones":{"iPhone":"\\biPhone\\b|\\biPod\\b","BlackBerry":"BlackBerry|\\bBB10\\b|rim[0-9]+|\\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\\b-[0-9]+","HTC":"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel","Nexus":"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6","Dell":"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b","Motorola":"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052","Samsung":"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F","LG":"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710","Sony":"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533","Asus":"Asus.*Galaxy|PadFone.*Mobile","NokiaLumia":"Lumia [0-9]{3,4}","Micromax":"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b","Palm":"PalmSource|Palm","Vertu":"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature","Pantech":"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790","Fly":"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250","Wiko":"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM","iMobile":"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)","SimValley":"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b","Wolfgang":"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q","Alcatel":"Alcatel","Nintendo":"Nintendo (3DS|Switch)","Amoi":"Amoi","INQ":"INQ","OnePlus":"ONEPLUS","GenericPhone":"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},"tablets":{"iPad":"iPad|iPad.*Mobile","NexusTablet":"Android.*Nexus[\\s]+(7|9|10)","GoogleTablet":"Android.*Pixel C","SamsungTablet":"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V","Kindle":"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk\/[0-9.]+ like Chrome\/[0-9.]+ (?!Mobile)","SurfaceTablet":"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)","HPTablet":"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10","AsusTablet":"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b","BlackBerryTablet":"PlayBook|RIM Tablet","HTCtablet":"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410","MotorolaTablet":"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617","NookTablet":"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2","AcerTablet":"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30","ToshibaTablet":"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO","LGTablet":"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b","FujitsuTablet":"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b","PrestigioTablet":"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002","LenovoTablet":"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X","DellTablet":"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7","YarvikTablet":"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b","MedionTablet":"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB","ArnovaTablet":"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2","IntensoTablet":"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004","IRUTablet":"M702pro","MegafonTablet":"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b","EbodaTablet":"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)","AllViewTablet":"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)","ArchosTablet":"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b","AinolTablet":"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark","NokiaLumiaTablet":"Lumia 2520","SonyTablet":"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712","PhilipsTablet":"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b","CubeTablet":"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT","CobyTablet":"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010","MIDTablet":"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10","MSITablet":"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b","SMiTTablet":"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)","RockChipTablet":"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A","FlyTablet":"IQ310|Fly Vision","bqTablet":"Android.*(bq)?.*\\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\\b|Maxwell.*Lite|Maxwell.*Plus","HuaweiTablet":"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19","NecTablet":"\\bN-06D|\\bN-08D","PantechTablet":"Pantech.*P4100","BronchoTablet":"Broncho.*(N701|N708|N802|a710)","VersusTablet":"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b","ZyncTablet":"z1000|Z99 2G|z930|z990|z909|Z919|z900","PositivoTablet":"TB07STA|TB10STA|TB07FTA|TB10FTA","NabiTablet":"Android.*\\bNabi","KoboTablet":"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build","DanewTablet":"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b","TexetTablet":"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE","PlaystationTablet":"Playstation.*(Portable|Vita)","TrekstorTablet":"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab","PyleAudioTablet":"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b","AdvanTablet":"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ","DanyTechTablet":"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1","GalapadTablet":"Android.*\\bG1\\b(?!\\))","MicromaxTablet":"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b","KarbonnTablet":"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b","AllFineTablet":"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide","PROSCANTablet":"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b","YONESTablet":"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026","ChangJiaTablet":"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503","GUTablet":"TX-A1301|TX-M9002|Q702|kf026","PointOfViewTablet":"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10","OvermaxTablet":"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027","HCLTablet":"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync","DPSTablet":"DPS Dream 9|DPS Dual 7","VistureTablet":"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10","CrestaTablet":"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989","MediatekTablet":"\\bMT8125|MT8389|MT8135|MT8377\\b","ConcordeTablet":"Concorde([ ]+)?Tab|ConCorde ReadMan","GoCleverTablet":"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042","ModecomTablet":"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003","VoninoTablet":"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b","ECSTablet":"V07OT2|TM105A|S10OT1|TR10CS1","StorexTablet":"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab","VodafoneTablet":"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400","EssentielBTablet":"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2","RossMoorTablet":"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711","iMobileTablet":"i-mobile i-note","TolinoTablet":"tolino tab [0-9.]+|tolino shine","AudioSonicTablet":"\\bC-22Q|T7-QC|T-17B|T-17P\\b","AMPETablet":"Android.* A78 ","SkkTablet":"Android.* (SKYPAD|PHOENIX|CYCLOPS)","TecnoTablet":"TECNO P9|TECNO DP8D","JXDTablet":"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b","iJoyTablet":"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)","FX2Tablet":"FX2 PAD7|FX2 PAD10","XoroTablet":"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151","ViewsonicTablet":"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a","VerizonTablet":"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1","OdysTablet":"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10","CaptivaTablet":"CAPTIVA PAD","IconbitTablet":"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S","TeclastTablet":"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi","OndaTablet":"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b","JaytechTablet":"TPC-PA762","BlaupunktTablet":"Endeavour 800NG|Endeavour 1010","DigmaTablet":"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b","EvolioTablet":"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b","LavaTablet":"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b","AocTablet":"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712","MpmanTablet":"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010","CelkonTablet":"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b","WolderTablet":"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b","MediacomTablet":"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA","MiTablet":"\\bMI PAD\\b|\\bHM NOTE 1W\\b","NibiruTablet":"Nibiru M1|Nibiru Jupiter One","NexoTablet":"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI","LeaderTablet":"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100","UbislateTablet":"UbiSlate[\\s]?7C","PocketBookTablet":"Pocketbook","KocasoTablet":"\\b(TB-1207)\\b","HisenseTablet":"\\b(F5281|E2371)\\b","Hudl":"Hudl HT7S3|Hudl 2","TelstraTablet":"T-Hub2","GenericTablet":"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},"browsers":{"Chrome":"\\bCrMo\\b|CriOS|Android.*Chrome\/[.0-9]* (Mobile)?","Dolfin":"\\bDolfin\\b","Opera":"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+$|Coast\/[0-9.]+","Skyfire":"Skyfire","Edge":"Mobile Safari\/[.0-9]* Edge","IE":"IEMobile|MSIEMobile","Firefox":"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS","Bolt":"bolt","TeaShark":"teashark","Blazer":"Blazer","Safari":"Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari","WeChat":"\\bMicroMessenger\\b","UCBrowser":"UC.*Browser|UCWEB","baiduboxapp":"baiduboxapp","baidubrowser":"baidubrowser","DiigoBrowser":"DiigoBrowser","Mercury":"\\bMercury\\b","ObigoBrowser":"Obigo","NetFront":"NF-Browser","GenericBrowser":"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger","PaleMoon":"Android.*PaleMoon|Mobile.*PaleMoon"},"os":{"AndroidOS":"Android","BlackBerryOS":"blackberry|\\bBB10\\b|rim tablet os","PalmOS":"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino","SymbianOS":"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b","WindowsMobileOS":"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;","WindowsPhoneOS":"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;","iOS":"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia","iPadOS":"CPU OS 13","MeeGoOS":"MeeGo","MaemoOS":"Maemo","JavaOS":"J2ME\/|\\bMIDP\\b|\\bCLDC\\b","webOS":"webOS|hpwOS","badaOS":"\\bBada\\b","BREWOS":"BREW"},"utilities":{"Bot":"Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp","MobileBot":"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker\/M1A1-R2D2","DesktopMode":"WPDesktop","TV":"SonyDTV|HbbTV","WebKit":"(webkit)[ \/]([\\w.]+)","Console":"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b","Watch":"SM-V700"}}} \ No newline at end of file diff --git a/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php b/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php index c65b3812f56..b105eb71771 100644 --- a/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php +++ b/htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php @@ -18,7 +18,7 @@ * @author Nick Ilyin * Original author: Victor Stanciu * - * @version 2.8.33 + * @version 2.8.34 */ class Mobile_Detect { @@ -61,7 +61,7 @@ class Mobile_Detect /** * Stores the version number of the current release. */ - const VERSION = '2.8.33'; + const VERSION = '2.8.34'; /** * A type for the version() method indicating a string return value. @@ -164,14 +164,14 @@ class Mobile_Detect */ protected static $phoneDevices = array( 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes - 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+', + 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+|\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\b-[0-9]+', 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel', 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6', // @todo: Is 'Dell Streak' a tablet or a phone? ;) 'Dell' => 'Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b', 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto E\b|XT1068|XT1092|XT1052', 'Samsung' => '\bSamsung\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F', - 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)', + 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710', 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533', 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile', 'NokiaLumia' => 'Lumia [0-9]{3,4}', @@ -201,6 +201,7 @@ class Mobile_Detect 'Amoi' => 'Amoi', // http://en.wikipedia.org/wiki/INQ 'INQ' => 'INQ', + 'OnePlus' => 'ONEPLUS', // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser', ); @@ -219,7 +220,7 @@ class Mobile_Detect 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)', // https://en.wikipedia.org/wiki/Pixel_C 'GoogleTablet' => 'Android.*Pixel C', - 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone. + 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)', // Only the Surface tablets with Windows RT are considered mobile. @@ -251,7 +252,7 @@ class Mobile_Detect // Prestigio Tablets http://www.prestigio.com/support 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002', // http://support.lenovo.com/en_GB/downloads/default.page?# - 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304F|TB-X304L|TB-8703F|Tab2A7-10F|TB2-X30L', + 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X', // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7', // http://www.yarvik.com/en/matrix/tablets/ @@ -301,10 +302,10 @@ class Mobile_Detect // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/ 'FlyTablet' => 'IQ310|Fly Vision', // http://www.bqreaders.com/gb/tablets-prices-sale.html - 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))|Maxwell.*Lite|Maxwell.*Plus', + 'bqTablet' => 'Android.*(bq)?.*\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\b|Maxwell.*Lite|Maxwell.*Plus', // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290 // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets) - 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09', + 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19', // Nec or Medias Tab 'NecTablet' => '\bN-06D|\bN-08D', // Pantech Tablets: http://www.pantechusa.com/phones/ @@ -314,7 +315,7 @@ class Mobile_Detect // http://versusuk.com/support.html 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b', // http://www.zync.in/index.php/our-products/tablet-phablets - 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900', + 'ZyncTablet' => 'z1000|Z99 2G|z930|z990|z909|Z919|z900', // Removed "z999" because of https://github.com/serbanghita/Mobile-Detect/issues/717 // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/ 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA', // https://www.nabitablet.com/ @@ -377,7 +378,7 @@ class Mobile_Detect 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042', // Modecom Tablets - http://www.modecom.eu/tablets/portal/ 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003', - // Vonino Tablets - http://www.vonino.eu/tablets + // Vonino Tablets 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b', // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1', @@ -385,7 +386,7 @@ class Mobile_Detect // @note: no need to add all the tablet codes since they are guided by the first regex. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab', // Generic Vodafone tablets. - 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497', + 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400', // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb // Aka: http://www.essentielb.fr/ 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2', @@ -484,7 +485,7 @@ class Mobile_Detect 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino', 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b', // @reference: http://en.wikipedia.org/wiki/Windows_Mobile - 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;', + 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;', // @reference: http://en.wikipedia.org/wiki/Windows_Phone // http://wifeng.cn/?r=blog&a=view&id=106 // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx @@ -492,6 +493,8 @@ class Mobile_Detect // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;', 'iOS' => '\biPhone.*Mobile|\biPod|\biPad|AppleCoreMedia', + // https://en.wikipedia.org/wiki/IPadOS + 'iPadOS' => 'CPU OS 13', // http://en.wikipedia.org/wiki/MeeGo // @todo: research MeeGo in UAs 'MeeGoOS' => 'MeeGo', @@ -539,7 +542,8 @@ class Mobile_Detect // https://github.com/serbanghita/Mobile-Detect/issues/7 'DiigoBrowser' => 'DiigoBrowser', // http://www.puffinbrowser.com/index.php - 'Puffin' => 'Puffin', + // https://github.com/serbanghita/Mobile-Detect/issues/752 + // 'Puffin' => 'Puffin', // http://mercury-browser.com/index.html 'Mercury' => '\bMercury\b', // http://en.wikipedia.org/wiki/Obigo_Browser @@ -563,7 +567,7 @@ class Mobile_Detect // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/ // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011 // https://developers.facebook.com/docs/sharing/best-practices - 'Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom', + 'Bot' => 'Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp', 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2', 'DesktopMode' => 'WPDesktop', 'TV' => 'SonyDTV|HbbTV', // experimental diff --git a/htdocs/includes/mobiledetect/mobiledetectlib/README.md b/htdocs/includes/mobiledetect/mobiledetectlib/README.md index 310d9f3661d..d73757b728f 100644 --- a/htdocs/includes/mobiledetect/mobiledetectlib/README.md +++ b/htdocs/includes/mobiledetect/mobiledetectlib/README.md @@ -68,13 +68,13 @@ or include the dependency in the `composer.json` file: #### Demo -* [:iphone: Live demo!](http://is.gd/mobiletest) +* [:iphone: Live demo!](http://demo.mobiledetect.net) * [Code examples](../../wiki/Code-examples) #### Contribute *Submit a PR* -> Submit a pull request but before make sure you read [how to contribute](../../docs/CONTRIBUTING.md) guide. +> Submit a pull request but before make sure you read [how to contribute](docs/CONTRIBUTING.md) guide. *Donate* @@ -92,7 +92,7 @@ Special thanks to the community :+1: for donations, JetBrains team for the conti > [Submit new module, plugin, port](../../issues/new?title=New%203rd%20party%20module&body=Name,%20Link%20and%20Description%20of%20the%20module.) :point_right: Keep `Mobile_Detect.php` class in a separate `module` and do NOT include it in your script core because of the high frequency of updates. -:point_right: When including the class into you `web application` or `module` always use `include_once '../path/to/Mobile_Detect.php` to prevent conflicts. +:point_right: When including the class into your `web application` or `module` always use `include_once '../path/to/Mobile_Detect.php` to prevent conflicts. **JavaScript** diff --git a/htdocs/includes/mobiledetect/mobiledetectlib/composer.json b/htdocs/includes/mobiledetect/mobiledetectlib/composer.json index 25cd99a375f..738f8f8831f 100644 --- a/htdocs/includes/mobiledetect/mobiledetectlib/composer.json +++ b/htdocs/includes/mobiledetect/mobiledetectlib/composer.json @@ -1,31 +1,42 @@ { - "name": "mobiledetect/mobiledetectlib", - "type": "library", - "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", - "keywords": ["mobile", "mobile detect", "mobile detector", "php mobile detect", "detect mobile devices"], - "homepage": "https://github.com/serbanghita/Mobile-Detect", - "license": "MIT", - "authors": [ - { - "name": "Serban Ghita", - "email": "serbanghita@gmail.com", - "homepage": "http://mobiledetect.net", - "role": "Developer" - } - ], - "require": { - "php": ">=5.0.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8.35||~5.7" - }, - "autoload": { - "classmap": ["Mobile_Detect.php"], - "psr-0": { - "Detection": "namespaced/" - } - }, - "archive": { - "exclude": ["docs", "examples", "export"] - } -} + "name" : "mobiledetect/mobiledetectlib", + "type" : "library", + "description" : "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", + "keywords" : [ + "mobile", + "mobile detect", + "mobile detector", + "php mobile detect", + "detect mobile devices" + ], + "homepage" : "https://github.com/serbanghita/Mobile-Detect", + "license" : "MIT", + "authors" : [{ + "name" : "Serban Ghita", + "email" : "serbanghita@gmail.com", + "homepage" : "http://mobiledetect.net", + "role" : "Developer" + } + ], + "require" : { + "php" : ">=5.0.0" + }, + "require-dev" : { + "phpunit/phpunit" : "~4.8.35||~5.7" + }, + "autoload" : { + "classmap" : [ + "Mobile_Detect.php" + ], + "psr-0" : { + "Detection" : "namespaced/" + } + }, + "archive" : { + "exclude" : [ + "docs", + "examples", + "export" + ] + } +} \ No newline at end of file diff --git a/htdocs/includes/mobiledetect/mobiledetectlib/docker-compose.yml b/htdocs/includes/mobiledetect/mobiledetectlib/docker-compose.yml new file mode 100644 index 00000000000..58ce75e879c --- /dev/null +++ b/htdocs/includes/mobiledetect/mobiledetectlib/docker-compose.yml @@ -0,0 +1,16 @@ +app: + restart: 'on-failure' + image: php:7 + working_dir: /app + command: vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-text --strict-coverage --stop-on-risky + ports: + - "8000:8000" + volumes: + - .:/app + +composer: + restart: 'no' + image: composer/composer:php7 + command: install + volumes: + - .:/app \ No newline at end of file diff --git a/htdocs/includes/mobiledetect/mobiledetectlib/docs/KNOWN_LIMITATIONS.md b/htdocs/includes/mobiledetect/mobiledetectlib/docs/KNOWN_LIMITATIONS.md index 8b5d461fe38..5887092f1f8 100644 --- a/htdocs/includes/mobiledetect/mobiledetectlib/docs/KNOWN_LIMITATIONS.md +++ b/htdocs/includes/mobiledetect/mobiledetectlib/docs/KNOWN_LIMITATIONS.md @@ -3,7 +3,8 @@ * Mobile Detect script was designed to detect `mobile` devices. Implicitly other devices are considered to be `desktop`. * User-Agent and HTTP headers sniffing is a non reliable method of detecting a mobile device. * If the mobile browser is set on `Desktop mode`, the Mobile Detect script has no way of knowing that the device is `mobile`. -* Some touchscreen devices (eg. Microsoft Surface) are tough to detect as mobile since they can be used in a laptop mode. +* Some touchscreen devices (eg. Microsoft Surface) are tough to detect as mobile since they can be used in a laptop mode. See: [#32](https://github.com/serbanghita/Mobile-Detect/issues/32), [#461](https://github.com/serbanghita/Mobile-Detect/issues/461), [#667](https://github.com/serbanghita/Mobile-Detect/issues/667) +* Some mobile devices (eg. IPadOS, Google Pixel Slate). See: [#795](https://github.com/serbanghita/Mobile-Detect/issues/795), [#788](https://github.com/serbanghita/Mobile-Detect/issues/788) * Detecting the device brand (eg. Apple, Samsung, HTC) is not 100% reliable. * We don't monitor the quality of the 3rd party tools based on Mobile Detect script. We cannot guarantee that they are using the class properly or if they provide the latest version. From 94589158c0e109ec6923a8d80d5ea3d60d95524e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 02:32:33 +0100 Subject: [PATCH 056/833] Move class from external project as internal class (project is dead) --- .../evalmath => core/class}/evalmath.class.php | 0 htdocs/includes/evalmath/README.md | 11 ----------- .../dynamic_price/class/price_parser.class.php | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) rename htdocs/{includes/evalmath => core/class}/evalmath.class.php (100%) delete mode 100755 htdocs/includes/evalmath/README.md diff --git a/htdocs/includes/evalmath/evalmath.class.php b/htdocs/core/class/evalmath.class.php similarity index 100% rename from htdocs/includes/evalmath/evalmath.class.php rename to htdocs/core/class/evalmath.class.php diff --git a/htdocs/includes/evalmath/README.md b/htdocs/includes/evalmath/README.md deleted file mode 100755 index 6011e3fb676..00000000000 --- a/htdocs/includes/evalmath/README.md +++ /dev/null @@ -1,11 +0,0 @@ -evalmath.class.php -================== - -Version 1.0 - -Taken from http://www.phpclasses.org/browse/file/11680.html, cred to Miles Kaufmann - -This repository is cloned for two reasons: - -1. To allow downloading the code without signing in to phpclasses.org. -2. To add very small improvements to the code. diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index d0eae2f3b17..6659dc56054 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -20,7 +20,7 @@ * \ingroup product * \brief File of class to calculate prices using expression */ -require_once DOL_DOCUMENT_ROOT.'/includes/evalmath/evalmath.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/evalmath.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_global_variable.class.php'; From f3996c00383f9ad501bb2fb3b96a9b8693645e5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 02:35:28 +0100 Subject: [PATCH 057/833] Code comment --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c92e7d4f7ac..1cea53ae2a7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1417,7 +1417,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; } - // jQuery jeditable + // jQuery jeditable for Edit In Place features if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE')) { print ''."\n"; From 35fae3ec5d73c781557073561438954063e774ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 03:07:28 +0100 Subject: [PATCH 058/833] NEW Upgrade Stripe library to 6.43.1 --- COPYRIGHT | 2 +- composer.json | 5 +- composer.lock | 58 +++++++++++++- htdocs/includes/stripe/VERSION | 1 - .../lib/SubscriptionScheduleRevision.php | 77 ------------------- .../includes/stripe/stripe-php/.editorconfig | 14 ++++ .../stripe/{ => stripe-php}/.gitignore | 0 .../stripe/{ => stripe-php}/CHANGELOG.md | 20 ++++- .../includes/stripe/{ => stripe-php}/LICENSE | 0 .../stripe/{ => stripe-php}/README.md | 0 htdocs/includes/stripe/stripe-php/VERSION | 1 + .../stripe/{ => stripe-php}/build.php | 0 .../stripe/{ => stripe-php}/composer.json | 0 .../{ => stripe-php}/data/ca-certificates.crt | 0 .../includes/stripe/{ => stripe-php}/init.php | 1 - .../stripe/{ => stripe-php}/lib/Account.php | 1 - .../{ => stripe-php}/lib/AccountLink.php | 1 - .../{ => stripe-php}/lib/AlipayAccount.php | 1 - .../lib/ApiOperations/All.php | 0 .../lib/ApiOperations/Create.php | 0 .../lib/ApiOperations/Delete.php | 0 .../lib/ApiOperations/NestedResource.php | 0 .../lib/ApiOperations/Request.php | 0 .../lib/ApiOperations/Retrieve.php | 0 .../lib/ApiOperations/Update.php | 0 .../{ => stripe-php}/lib/ApiRequestor.php | 2 +- .../{ => stripe-php}/lib/ApiResource.php | 0 .../{ => stripe-php}/lib/ApiResponse.php | 4 +- .../{ => stripe-php}/lib/ApplePayDomain.php | 1 - .../{ => stripe-php}/lib/ApplicationFee.php | 1 - .../lib/ApplicationFeeRefund.php | 1 - .../stripe/{ => stripe-php}/lib/Balance.php | 1 - .../lib/BalanceTransaction.php | 1 - .../{ => stripe-php}/lib/BankAccount.php | 13 ++-- .../{ => stripe-php}/lib/BitcoinReceiver.php | 1 - .../lib/BitcoinTransaction.php | 1 - .../{ => stripe-php}/lib/Capability.php | 1 - .../stripe/{ => stripe-php}/lib/Card.php | 1 - .../stripe/{ => stripe-php}/lib/Charge.php | 1 - .../{ => stripe-php}/lib/Checkout/Session.php | 1 - .../{ => stripe-php}/lib/Collection.php | 1 - .../{ => stripe-php}/lib/CountrySpec.php | 1 - .../stripe/{ => stripe-php}/lib/Coupon.php | 1 - .../{ => stripe-php}/lib/CreditNote.php | 1 - .../stripe/{ => stripe-php}/lib/Customer.php | 1 - .../lib/CustomerBalanceTransaction.php | 0 .../stripe/{ => stripe-php}/lib/Discount.php | 1 - .../stripe/{ => stripe-php}/lib/Dispute.php | 1 - .../{ => stripe-php}/lib/EphemeralKey.php | 1 - .../stripe/{ => stripe-php}/lib/Error/Api.php | 0 .../lib/Error/ApiConnection.php | 0 .../lib/Error/Authentication.php | 0 .../{ => stripe-php}/lib/Error/Base.php | 0 .../{ => stripe-php}/lib/Error/Card.php | 0 .../lib/Error/Idempotency.php | 0 .../lib/Error/InvalidRequest.php | 0 .../lib/Error/OAuth/InvalidClient.php | 0 .../lib/Error/OAuth/InvalidGrant.php | 0 .../lib/Error/OAuth/InvalidRequest.php | 0 .../lib/Error/OAuth/InvalidScope.php | 0 .../lib/Error/OAuth/OAuthBase.php | 0 .../lib/Error/OAuth/UnsupportedGrantType.php | 0 .../Error/OAuth/UnsupportedResponseType.php | 0 .../{ => stripe-php}/lib/Error/Permission.php | 0 .../{ => stripe-php}/lib/Error/RateLimit.php | 0 .../lib/Error/SignatureVerification.php | 0 .../stripe/{ => stripe-php}/lib/Event.php | 1 - .../{ => stripe-php}/lib/ExchangeRate.php | 1 - .../stripe/{ => stripe-php}/lib/File.php | 0 .../stripe/{ => stripe-php}/lib/FileLink.php | 1 - .../{ => stripe-php}/lib/FileUpload.php | 0 .../lib/HttpClient/ClientInterface.php | 0 .../lib/HttpClient/CurlClient.php | 0 .../stripe/{ => stripe-php}/lib/Invoice.php | 1 - .../{ => stripe-php}/lib/InvoiceItem.php | 1 - .../{ => stripe-php}/lib/InvoiceLineItem.php | 0 .../lib/IssuerFraudRecord.php | 1 - .../lib/Issuing/Authorization.php | 0 .../{ => stripe-php}/lib/Issuing/Card.php | 0 .../lib/Issuing/CardDetails.php | 0 .../lib/Issuing/Cardholder.php | 0 .../{ => stripe-php}/lib/Issuing/Dispute.php | 0 .../lib/Issuing/Transaction.php | 0 .../stripe/{ => stripe-php}/lib/LoginLink.php | 1 - .../stripe/{ => stripe-php}/lib/OAuth.php | 0 .../stripe/{ => stripe-php}/lib/Order.php | 1 - .../stripe/{ => stripe-php}/lib/OrderItem.php | 1 - .../{ => stripe-php}/lib/OrderReturn.php | 1 - .../{ => stripe-php}/lib/PaymentIntent.php | 1 - .../{ => stripe-php}/lib/PaymentMethod.php | 1 - .../stripe/{ => stripe-php}/lib/Payout.php | 1 - .../stripe/{ => stripe-php}/lib/Person.php | 1 - .../stripe/{ => stripe-php}/lib/Plan.php | 1 - .../stripe/{ => stripe-php}/lib/Product.php | 1 - .../lib/Radar/EarlyFraudWarning.php | 0 .../{ => stripe-php}/lib/Radar/ValueList.php | 0 .../lib/Radar/ValueListItem.php | 0 .../stripe/{ => stripe-php}/lib/Recipient.php | 1 - .../lib/RecipientTransfer.php | 1 - .../stripe/{ => stripe-php}/lib/Refund.php | 1 - .../lib/Reporting/ReportRun.php | 0 .../lib/Reporting/ReportType.php | 0 .../{ => stripe-php}/lib/RequestTelemetry.php | 0 .../stripe/{ => stripe-php}/lib/Review.php | 0 .../stripe/{ => stripe-php}/lib/SKU.php | 1 - .../{ => stripe-php}/lib/SetupIntent.php | 1 - .../lib/Sigma/ScheduledQueryRun.php | 0 .../lib/SingletonApiResource.php | 0 .../stripe/{ => stripe-php}/lib/Source.php | 1 - .../lib/SourceTransaction.php | 1 - .../stripe/{ => stripe-php}/lib/Stripe.php | 4 +- .../{ => stripe-php}/lib/StripeObject.php | 2 +- .../{ => stripe-php}/lib/Subscription.php | 2 +- .../{ => stripe-php}/lib/SubscriptionItem.php | 18 ++++- .../lib/SubscriptionSchedule.php | 43 ----------- .../stripe/{ => stripe-php}/lib/TaxId.php | 1 - .../stripe/{ => stripe-php}/lib/TaxRate.php | 1 - .../lib/Terminal/ConnectionToken.php | 0 .../lib/Terminal/Location.php | 0 .../{ => stripe-php}/lib/Terminal/Reader.php | 0 .../{ => stripe-php}/lib/ThreeDSecure.php | 1 - .../stripe/{ => stripe-php}/lib/Token.php | 1 - .../stripe/{ => stripe-php}/lib/Topup.php | 1 - .../stripe/{ => stripe-php}/lib/Transfer.php | 1 - .../{ => stripe-php}/lib/TransferReversal.php | 1 - .../{ => stripe-php}/lib/UsageRecord.php | 1 - .../lib/UsageRecordSummary.php | 1 - .../lib/Util/AutoPagingIterator.php | 0 .../lib/Util/CaseInsensitiveArray.php | 0 .../lib/Util/DefaultLogger.php | 0 .../lib/Util/LoggerInterface.php | 2 +- .../lib/Util/RandomGenerator.php | 0 .../lib/Util/RequestOptions.php | 0 .../stripe/{ => stripe-php}/lib/Util/Set.php | 0 .../stripe/{ => stripe-php}/lib/Util/Util.php | 1 - .../stripe/{ => stripe-php}/lib/Webhook.php | 0 .../{ => stripe-php}/lib/WebhookEndpoint.php | 1 - .../{ => stripe-php}/lib/WebhookSignature.php | 0 .../stripe/{ => stripe-php}/update_certs.php | 0 htdocs/public/payment/newpayment.php | 2 +- htdocs/public/stripe/confirm_payment.php | 2 +- htdocs/public/stripe/ipn.php | 2 +- htdocs/stripe/config.php | 4 +- 143 files changed, 129 insertions(+), 206 deletions(-) delete mode 100644 htdocs/includes/stripe/VERSION delete mode 100644 htdocs/includes/stripe/lib/SubscriptionScheduleRevision.php create mode 100644 htdocs/includes/stripe/stripe-php/.editorconfig rename htdocs/includes/stripe/{ => stripe-php}/.gitignore (100%) rename htdocs/includes/stripe/{ => stripe-php}/CHANGELOG.md (96%) rename htdocs/includes/stripe/{ => stripe-php}/LICENSE (100%) rename htdocs/includes/stripe/{ => stripe-php}/README.md (100%) create mode 100644 htdocs/includes/stripe/stripe-php/VERSION rename htdocs/includes/stripe/{ => stripe-php}/build.php (100%) mode change 100644 => 100755 rename htdocs/includes/stripe/{ => stripe-php}/composer.json (100%) rename htdocs/includes/stripe/{ => stripe-php}/data/ca-certificates.crt (100%) rename htdocs/includes/stripe/{ => stripe-php}/init.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Account.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/AccountLink.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/AlipayAccount.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/All.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/Create.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/Delete.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/NestedResource.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/Request.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/Retrieve.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiOperations/Update.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiRequestor.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiResource.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApiResponse.php (84%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApplePayDomain.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApplicationFee.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ApplicationFeeRefund.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Balance.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/BalanceTransaction.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/BankAccount.php (95%) rename htdocs/includes/stripe/{ => stripe-php}/lib/BitcoinReceiver.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/BitcoinTransaction.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Capability.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Card.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Charge.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Checkout/Session.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Collection.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/CountrySpec.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Coupon.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/CreditNote.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Customer.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/CustomerBalanceTransaction.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Discount.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Dispute.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/EphemeralKey.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/Api.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/ApiConnection.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/Authentication.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/Base.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/Card.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/Idempotency.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/InvalidRequest.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/InvalidClient.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/InvalidGrant.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/InvalidRequest.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/InvalidScope.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/OAuthBase.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/UnsupportedGrantType.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/OAuth/UnsupportedResponseType.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/Permission.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/RateLimit.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Error/SignatureVerification.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Event.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ExchangeRate.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/File.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/FileLink.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/FileUpload.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/HttpClient/ClientInterface.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/HttpClient/CurlClient.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Invoice.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/InvoiceItem.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/InvoiceLineItem.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/IssuerFraudRecord.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Issuing/Authorization.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Issuing/Card.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Issuing/CardDetails.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Issuing/Cardholder.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Issuing/Dispute.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Issuing/Transaction.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/LoginLink.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/OAuth.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Order.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/OrderItem.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/OrderReturn.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/PaymentIntent.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/PaymentMethod.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Payout.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Person.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Plan.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Product.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Radar/EarlyFraudWarning.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Radar/ValueList.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Radar/ValueListItem.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Recipient.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/RecipientTransfer.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Refund.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Reporting/ReportRun.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Reporting/ReportType.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/RequestTelemetry.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Review.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/SKU.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/SetupIntent.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Sigma/ScheduledQueryRun.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/SingletonApiResource.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Source.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/SourceTransaction.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Stripe.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/StripeObject.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Subscription.php (98%) rename htdocs/includes/stripe/{ => stripe-php}/lib/SubscriptionItem.php (65%) rename htdocs/includes/stripe/{ => stripe-php}/lib/SubscriptionSchedule.php (56%) rename htdocs/includes/stripe/{ => stripe-php}/lib/TaxId.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/TaxRate.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Terminal/ConnectionToken.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Terminal/Location.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Terminal/Reader.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/ThreeDSecure.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Token.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Topup.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Transfer.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/TransferReversal.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/UsageRecord.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/UsageRecordSummary.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/AutoPagingIterator.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/CaseInsensitiveArray.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/DefaultLogger.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/LoggerInterface.php (98%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/RandomGenerator.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/RequestOptions.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/Set.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Util/Util.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/Webhook.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/lib/WebhookEndpoint.php (99%) rename htdocs/includes/stripe/{ => stripe-php}/lib/WebhookSignature.php (100%) rename htdocs/includes/stripe/{ => stripe-php}/update_certs.php (100%) mode change 100644 => 100755 diff --git a/COPYRIGHT b/COPYRIGHT index 1df1167fd5d..c1f400aff4e 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -32,7 +32,7 @@ PSR/simple-cache ? Library for cache (used by PHPSp Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Sabre 3.2.2 BSD Yes DAV support Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP -Stripe 6.41 MIT licence Yes Library for Stripe module +Stripe 6.43.1 MIT licence Yes Library for Stripe module TCPDF 6.3.2 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement diff --git a/composer.json b/composer.json index c61f985c5bf..69d6a249d32 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "phpoffice/phpexcel" : "1.8.1", "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", - "nnnick/chartjs" : "2.9.3" + "nnnick/chartjs" : "2.9.3", + "stripe/stripe-php" : "6.43.1" }, "require-dev" : { "jakub-onderka/php-parallel-lint" : "^0", @@ -56,4 +57,4 @@ "ext-zip" : "ODT, Excel and file compression support", "ext-xml" : "Excel support" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 93a6a621e56..b9db7f70d11 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "3c03efa3fe59b85d3d389e01cc65812b", + "content-hash": "870cfae419450a7944a169612d204989", "packages": [ { "name": "ckeditor/ckeditor", @@ -314,6 +314,62 @@ ], "time": "2019-05-12T15:15:11+00:00" }, + { + "name": "stripe/stripe-php", + "version": "v6.43.1", + "source": { + "type": "git", + "url": "https://github.com/stripe/stripe-php.git", + "reference": "42fcdaf99c44bb26937223f8eae1f263491d5ab8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/42fcdaf99c44bb26937223f8eae1f263491d5ab8", + "reference": "42fcdaf99c44bb26937223f8eae1f263491d5ab8", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "1.*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0", + "symfony/process": "~2.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Stripe\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stripe and contributors", + "homepage": "https://github.com/stripe/stripe-php/contributors" + } + ], + "description": "Stripe PHP Library", + "homepage": "https://stripe.com/", + "keywords": [ + "api", + "payment processing", + "stripe" + ], + "time": "2019-08-29T16:56:12+00:00" + }, { "name": "tecnickcom/tcpdf", "version": "6.3.2", diff --git a/htdocs/includes/stripe/VERSION b/htdocs/includes/stripe/VERSION deleted file mode 100644 index 08c99ad1b68..00000000000 --- a/htdocs/includes/stripe/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.41.0 diff --git a/htdocs/includes/stripe/lib/SubscriptionScheduleRevision.php b/htdocs/includes/stripe/lib/SubscriptionScheduleRevision.php deleted file mode 100644 index 12177236530..00000000000 --- a/htdocs/includes/stripe/lib/SubscriptionScheduleRevision.php +++ /dev/null @@ -1,77 +0,0 @@ -retrieveRevision('revision_id') instead."; - throw new Error\InvalidRequest($msg, null); - } - - /** - * @param array|string $_id - * @param array|string|null $_opts - * - * @throws \Stripe\Error\InvalidRequest - */ - public static function all($params = null, $opts = null) - { - $msg = "Subscription Schedule Revisions cannot be listed without a Subscription Schedule ID. " . - "List those using \$schedule->allRevisions('revision_id') instead."; - throw new Error\InvalidRequest($msg, null); - } -} diff --git a/htdocs/includes/stripe/stripe-php/.editorconfig b/htdocs/includes/stripe/stripe-php/.editorconfig new file mode 100644 index 00000000000..9e93e0c4c3e --- /dev/null +++ b/htdocs/includes/stripe/stripe-php/.editorconfig @@ -0,0 +1,14 @@ +; https://editorconfig.org/ + +root = true + +[*] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +charset = utf-8 + +[*.{json,yml}] +indent_size = 2 diff --git a/htdocs/includes/stripe/.gitignore b/htdocs/includes/stripe/stripe-php/.gitignore similarity index 100% rename from htdocs/includes/stripe/.gitignore rename to htdocs/includes/stripe/stripe-php/.gitignore diff --git a/htdocs/includes/stripe/CHANGELOG.md b/htdocs/includes/stripe/stripe-php/CHANGELOG.md similarity index 96% rename from htdocs/includes/stripe/CHANGELOG.md rename to htdocs/includes/stripe/stripe-php/CHANGELOG.md index bed9cff5722..5554f4ceb1f 100644 --- a/htdocs/includes/stripe/CHANGELOG.md +++ b/htdocs/includes/stripe/stripe-php/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 6.43.1 - 2019-08-29 +* [#722](https://github.com/stripe/stripe-php/pull/722) Make `LoggerInterface::error` compatible with its PSR-3 counterpart +* [#714](https://github.com/stripe/stripe-php/pull/714) Add `pending_setup_intent` property in `Subscription` +* [#713](https://github.com/stripe/stripe-php/pull/713) Add typehint to `ApiResponse` +* [#712](https://github.com/stripe/stripe-php/pull/712) Fix comment +* [#701](https://github.com/stripe/stripe-php/pull/701) Start testing PHP 7.3 + +## 6.43.0 - 2019-08-09 +* [#694](https://github.com/stripe/stripe-php/pull/694) Add `SubscriptionItem::createUsageRecord` method + +## 6.42.0 - 2019-08-09 +* [#688](https://github.com/stripe/stripe-php/pull/688) Remove `SubscriptionScheduleRevision` + * Note that this is technically a breaking change, however we've chosen to release it as a minor version in light of the fact that this resource and its API methods were virtually unused. + ## 6.41.0 - 2019-07-31 * [#683](https://github.com/stripe/stripe-php/pull/683) Move the List Balance History API to `/v1/balance_transactions` @@ -60,7 +74,7 @@ * [#642](https://github.com/stripe/stripe-php/pull/642) Fix an issue where existing idempotency keys would be overwritten when using automatic retries ## 6.34.1 - 2019-04-25 -* [#640](https://github.com/stripe/stripe-php/pull/640) Add missing phpdocs +* [#640](https://github.com/stripe/stripe-php/pull/640) Add missing phpdocs ## 6.34.0 - 2019-04-24 * [#626](https://github.com/stripe/stripe-php/pull/626) Add support for the `TaxRate` resource and APIs @@ -148,7 +162,7 @@ * [#564](https://github.com/stripe/stripe-php/pull/564) Add event name constants for subscription schedule aborted/expiring ## 6.23.0 - 2018-11-27 -* [#542](https://github.com/stripe/stripe-php/pull/542) Add support for `ValueList` and `ValueListItem` for Radar +* [#542](https://github.com/stripe/stripe-php/pull/542) Add support for `ValueList` and `ValueListItem` for Radar ## 6.22.1 - 2018-11-20 * [#561](https://github.com/stripe/stripe-php/pull/561) Add cast and some docs to telemetry introduced in 6.22.0/#549 @@ -402,7 +416,7 @@ Pull requests included in this release: * Add support for payouts and recipient transfers ## 4.6.0 - 2017-04-06 -* Please see 4.7.0 instead (no-op release) +* Please see 4.7.0 instead (no-op release) ## 4.5.1 - 2017-03-22 * Remove hard dependency on cURL diff --git a/htdocs/includes/stripe/LICENSE b/htdocs/includes/stripe/stripe-php/LICENSE similarity index 100% rename from htdocs/includes/stripe/LICENSE rename to htdocs/includes/stripe/stripe-php/LICENSE diff --git a/htdocs/includes/stripe/README.md b/htdocs/includes/stripe/stripe-php/README.md similarity index 100% rename from htdocs/includes/stripe/README.md rename to htdocs/includes/stripe/stripe-php/README.md diff --git a/htdocs/includes/stripe/stripe-php/VERSION b/htdocs/includes/stripe/stripe-php/VERSION new file mode 100644 index 00000000000..eb34ef6cbc3 --- /dev/null +++ b/htdocs/includes/stripe/stripe-php/VERSION @@ -0,0 +1 @@ +6.43.1 diff --git a/htdocs/includes/stripe/build.php b/htdocs/includes/stripe/stripe-php/build.php old mode 100644 new mode 100755 similarity index 100% rename from htdocs/includes/stripe/build.php rename to htdocs/includes/stripe/stripe-php/build.php diff --git a/htdocs/includes/stripe/composer.json b/htdocs/includes/stripe/stripe-php/composer.json similarity index 100% rename from htdocs/includes/stripe/composer.json rename to htdocs/includes/stripe/stripe-php/composer.json diff --git a/htdocs/includes/stripe/data/ca-certificates.crt b/htdocs/includes/stripe/stripe-php/data/ca-certificates.crt similarity index 100% rename from htdocs/includes/stripe/data/ca-certificates.crt rename to htdocs/includes/stripe/stripe-php/data/ca-certificates.crt diff --git a/htdocs/includes/stripe/init.php b/htdocs/includes/stripe/stripe-php/init.php similarity index 99% rename from htdocs/includes/stripe/init.php rename to htdocs/includes/stripe/stripe-php/init.php index e893cfcda90..05243999637 100644 --- a/htdocs/includes/stripe/init.php +++ b/htdocs/includes/stripe/stripe-php/init.php @@ -122,7 +122,6 @@ require(dirname(__FILE__) . '/lib/SourceTransaction.php'); require(dirname(__FILE__) . '/lib/Subscription.php'); require(dirname(__FILE__) . '/lib/SubscriptionItem.php'); require(dirname(__FILE__) . '/lib/SubscriptionSchedule.php'); -require(dirname(__FILE__) . '/lib/SubscriptionScheduleRevision.php'); require(dirname(__FILE__) . '/lib/TaxId.php'); require(dirname(__FILE__) . '/lib/TaxRate.php'); require(dirname(__FILE__) . '/lib/Terminal/ConnectionToken.php'); diff --git a/htdocs/includes/stripe/lib/Account.php b/htdocs/includes/stripe/stripe-php/lib/Account.php similarity index 99% rename from htdocs/includes/stripe/lib/Account.php rename to htdocs/includes/stripe/stripe-php/lib/Account.php index 1adc6b79d53..4993ca35414 100644 --- a/htdocs/includes/stripe/lib/Account.php +++ b/htdocs/includes/stripe/stripe-php/lib/Account.php @@ -30,7 +30,6 @@ namespace Stripe; */ class Account extends ApiResource { - const OBJECT_NAME = "account"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/AccountLink.php b/htdocs/includes/stripe/stripe-php/lib/AccountLink.php similarity index 99% rename from htdocs/includes/stripe/lib/AccountLink.php rename to htdocs/includes/stripe/stripe-php/lib/AccountLink.php index f2975ae3834..692447dbf69 100644 --- a/htdocs/includes/stripe/lib/AccountLink.php +++ b/htdocs/includes/stripe/stripe-php/lib/AccountLink.php @@ -14,7 +14,6 @@ namespace Stripe; */ class AccountLink extends ApiResource { - const OBJECT_NAME = "account_link"; use ApiOperations\Create; diff --git a/htdocs/includes/stripe/lib/AlipayAccount.php b/htdocs/includes/stripe/stripe-php/lib/AlipayAccount.php similarity index 99% rename from htdocs/includes/stripe/lib/AlipayAccount.php rename to htdocs/includes/stripe/stripe-php/lib/AlipayAccount.php index 70a281bd768..a79705fa4eb 100644 --- a/htdocs/includes/stripe/lib/AlipayAccount.php +++ b/htdocs/includes/stripe/stripe-php/lib/AlipayAccount.php @@ -12,7 +12,6 @@ namespace Stripe; */ class AlipayAccount extends ApiResource { - const OBJECT_NAME = "alipay_account"; use ApiOperations\Delete; diff --git a/htdocs/includes/stripe/lib/ApiOperations/All.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/All.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/All.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/All.php diff --git a/htdocs/includes/stripe/lib/ApiOperations/Create.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/Create.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/Create.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/Create.php diff --git a/htdocs/includes/stripe/lib/ApiOperations/Delete.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/Delete.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/Delete.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/Delete.php diff --git a/htdocs/includes/stripe/lib/ApiOperations/NestedResource.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/NestedResource.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/NestedResource.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/NestedResource.php diff --git a/htdocs/includes/stripe/lib/ApiOperations/Request.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/Request.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/Request.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/Request.php diff --git a/htdocs/includes/stripe/lib/ApiOperations/Retrieve.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/Retrieve.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/Retrieve.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/Retrieve.php diff --git a/htdocs/includes/stripe/lib/ApiOperations/Update.php b/htdocs/includes/stripe/stripe-php/lib/ApiOperations/Update.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiOperations/Update.php rename to htdocs/includes/stripe/stripe-php/lib/ApiOperations/Update.php diff --git a/htdocs/includes/stripe/lib/ApiRequestor.php b/htdocs/includes/stripe/stripe-php/lib/ApiRequestor.php similarity index 99% rename from htdocs/includes/stripe/lib/ApiRequestor.php rename to htdocs/includes/stripe/stripe-php/lib/ApiRequestor.php index 7cf851877de..1f75a007b32 100644 --- a/htdocs/includes/stripe/lib/ApiRequestor.php +++ b/htdocs/includes/stripe/stripe-php/lib/ApiRequestor.php @@ -205,7 +205,7 @@ class ApiRequestor return new Error\Idempotency($msg, $rcode, $rbody, $resp, $rheaders); } - // intentional fall-through + // no break case 404: return new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders); case 401: diff --git a/htdocs/includes/stripe/lib/ApiResource.php b/htdocs/includes/stripe/stripe-php/lib/ApiResource.php similarity index 100% rename from htdocs/includes/stripe/lib/ApiResource.php rename to htdocs/includes/stripe/stripe-php/lib/ApiResource.php diff --git a/htdocs/includes/stripe/lib/ApiResponse.php b/htdocs/includes/stripe/stripe-php/lib/ApiResponse.php similarity index 84% rename from htdocs/includes/stripe/lib/ApiResponse.php rename to htdocs/includes/stripe/stripe-php/lib/ApiResponse.php index 31f54a50df0..acca75123e6 100644 --- a/htdocs/includes/stripe/lib/ApiResponse.php +++ b/htdocs/includes/stripe/stripe-php/lib/ApiResponse.php @@ -2,6 +2,8 @@ namespace Stripe; +use Stripe\Util\CaseInsensitiveArray; + /** * Class ApiResponse * @@ -17,7 +19,7 @@ class ApiResponse /** * @param string $body * @param integer $code - * @param array|null $headers + * @param array|CaseInsensitiveArray|null $headers * @param array|null $json * * @return obj An APIResponse diff --git a/htdocs/includes/stripe/lib/ApplePayDomain.php b/htdocs/includes/stripe/stripe-php/lib/ApplePayDomain.php similarity index 99% rename from htdocs/includes/stripe/lib/ApplePayDomain.php rename to htdocs/includes/stripe/stripe-php/lib/ApplePayDomain.php index ea84220a7a9..57687c4f2e4 100644 --- a/htdocs/includes/stripe/lib/ApplePayDomain.php +++ b/htdocs/includes/stripe/stripe-php/lib/ApplePayDomain.php @@ -9,7 +9,6 @@ namespace Stripe; */ class ApplePayDomain extends ApiResource { - const OBJECT_NAME = "apple_pay_domain"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/ApplicationFee.php b/htdocs/includes/stripe/stripe-php/lib/ApplicationFee.php similarity index 99% rename from htdocs/includes/stripe/lib/ApplicationFee.php rename to htdocs/includes/stripe/stripe-php/lib/ApplicationFee.php index 0d9fde4c521..4b83071ade4 100644 --- a/htdocs/includes/stripe/lib/ApplicationFee.php +++ b/htdocs/includes/stripe/stripe-php/lib/ApplicationFee.php @@ -24,7 +24,6 @@ namespace Stripe; */ class ApplicationFee extends ApiResource { - const OBJECT_NAME = "application_fee"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/ApplicationFeeRefund.php b/htdocs/includes/stripe/stripe-php/lib/ApplicationFeeRefund.php similarity index 99% rename from htdocs/includes/stripe/lib/ApplicationFeeRefund.php rename to htdocs/includes/stripe/stripe-php/lib/ApplicationFeeRefund.php index 91d7e9d2bc6..b242f2024b4 100644 --- a/htdocs/includes/stripe/lib/ApplicationFeeRefund.php +++ b/htdocs/includes/stripe/stripe-php/lib/ApplicationFeeRefund.php @@ -18,7 +18,6 @@ namespace Stripe; */ class ApplicationFeeRefund extends ApiResource { - const OBJECT_NAME = "fee_refund"; use ApiOperations\Update { diff --git a/htdocs/includes/stripe/lib/Balance.php b/htdocs/includes/stripe/stripe-php/lib/Balance.php similarity index 99% rename from htdocs/includes/stripe/lib/Balance.php rename to htdocs/includes/stripe/stripe-php/lib/Balance.php index 25f88ae74c7..b99871adb85 100644 --- a/htdocs/includes/stripe/lib/Balance.php +++ b/htdocs/includes/stripe/stripe-php/lib/Balance.php @@ -15,7 +15,6 @@ namespace Stripe; */ class Balance extends SingletonApiResource { - const OBJECT_NAME = "balance"; /** diff --git a/htdocs/includes/stripe/lib/BalanceTransaction.php b/htdocs/includes/stripe/stripe-php/lib/BalanceTransaction.php similarity index 99% rename from htdocs/includes/stripe/lib/BalanceTransaction.php rename to htdocs/includes/stripe/stripe-php/lib/BalanceTransaction.php index 403c4aa173e..78805d4d448 100644 --- a/htdocs/includes/stripe/lib/BalanceTransaction.php +++ b/htdocs/includes/stripe/stripe-php/lib/BalanceTransaction.php @@ -24,7 +24,6 @@ namespace Stripe; */ class BalanceTransaction extends ApiResource { - const OBJECT_NAME = "balance_transaction"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/BankAccount.php b/htdocs/includes/stripe/stripe-php/lib/BankAccount.php similarity index 95% rename from htdocs/includes/stripe/lib/BankAccount.php rename to htdocs/includes/stripe/stripe-php/lib/BankAccount.php index 3fdc9188c64..a77f3054ba5 100644 --- a/htdocs/includes/stripe/lib/BankAccount.php +++ b/htdocs/includes/stripe/stripe-php/lib/BankAccount.php @@ -25,7 +25,6 @@ namespace Stripe; */ class BankAccount extends ApiResource { - const OBJECT_NAME = "bank_account"; use ApiOperations\Delete; @@ -93,12 +92,12 @@ class BankAccount extends ApiResource throw new Error\InvalidRequest($msg, null); } - /** - * @param array|null $params - * @param array|string|null $options - * - * @return BankAccount The verified bank account. - */ + /** + * @param array|null $params + * @param array|string|null $options + * + * @return BankAccount The verified bank account. + */ public function verify($params = null, $options = null) { $url = $this->instanceUrl() . '/verify'; diff --git a/htdocs/includes/stripe/lib/BitcoinReceiver.php b/htdocs/includes/stripe/stripe-php/lib/BitcoinReceiver.php similarity index 99% rename from htdocs/includes/stripe/lib/BitcoinReceiver.php rename to htdocs/includes/stripe/stripe-php/lib/BitcoinReceiver.php index b4cc5291b56..a9272dfa288 100644 --- a/htdocs/includes/stripe/lib/BitcoinReceiver.php +++ b/htdocs/includes/stripe/stripe-php/lib/BitcoinReceiver.php @@ -12,7 +12,6 @@ namespace Stripe; */ class BitcoinReceiver extends ApiResource { - const OBJECT_NAME = "bitcoin_receiver"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/BitcoinTransaction.php b/htdocs/includes/stripe/stripe-php/lib/BitcoinTransaction.php similarity index 99% rename from htdocs/includes/stripe/lib/BitcoinTransaction.php rename to htdocs/includes/stripe/stripe-php/lib/BitcoinTransaction.php index 8269fd216eb..122be42314f 100644 --- a/htdocs/includes/stripe/lib/BitcoinTransaction.php +++ b/htdocs/includes/stripe/stripe-php/lib/BitcoinTransaction.php @@ -9,6 +9,5 @@ namespace Stripe; */ class BitcoinTransaction extends ApiResource { - const OBJECT_NAME = "bitcoin_transaction"; } diff --git a/htdocs/includes/stripe/lib/Capability.php b/htdocs/includes/stripe/stripe-php/lib/Capability.php similarity index 99% rename from htdocs/includes/stripe/lib/Capability.php rename to htdocs/includes/stripe/stripe-php/lib/Capability.php index 78cb0393695..aabf54b1f1b 100644 --- a/htdocs/includes/stripe/lib/Capability.php +++ b/htdocs/includes/stripe/stripe-php/lib/Capability.php @@ -17,7 +17,6 @@ namespace Stripe; */ class Capability extends ApiResource { - const OBJECT_NAME = "capability"; use ApiOperations\Update; diff --git a/htdocs/includes/stripe/lib/Card.php b/htdocs/includes/stripe/stripe-php/lib/Card.php similarity index 99% rename from htdocs/includes/stripe/lib/Card.php rename to htdocs/includes/stripe/stripe-php/lib/Card.php index 40de733e780..51eb5add1c9 100644 --- a/htdocs/includes/stripe/lib/Card.php +++ b/htdocs/includes/stripe/stripe-php/lib/Card.php @@ -38,7 +38,6 @@ namespace Stripe; */ class Card extends ApiResource { - const OBJECT_NAME = "card"; use ApiOperations\Delete; diff --git a/htdocs/includes/stripe/lib/Charge.php b/htdocs/includes/stripe/stripe-php/lib/Charge.php similarity index 99% rename from htdocs/includes/stripe/lib/Charge.php rename to htdocs/includes/stripe/stripe-php/lib/Charge.php index 43274c5559c..0c3853c9678 100644 --- a/htdocs/includes/stripe/lib/Charge.php +++ b/htdocs/includes/stripe/stripe-php/lib/Charge.php @@ -53,7 +53,6 @@ namespace Stripe; */ class Charge extends ApiResource { - const OBJECT_NAME = "charge"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Checkout/Session.php b/htdocs/includes/stripe/stripe-php/lib/Checkout/Session.php similarity index 99% rename from htdocs/includes/stripe/lib/Checkout/Session.php rename to htdocs/includes/stripe/stripe-php/lib/Checkout/Session.php index 33fc6a08ab2..227dd7b6816 100644 --- a/htdocs/includes/stripe/lib/Checkout/Session.php +++ b/htdocs/includes/stripe/stripe-php/lib/Checkout/Session.php @@ -23,7 +23,6 @@ namespace Stripe\Checkout; */ class Session extends \Stripe\ApiResource { - const OBJECT_NAME = "checkout.session"; use \Stripe\ApiOperations\Create; diff --git a/htdocs/includes/stripe/lib/Collection.php b/htdocs/includes/stripe/stripe-php/lib/Collection.php similarity index 99% rename from htdocs/includes/stripe/lib/Collection.php rename to htdocs/includes/stripe/stripe-php/lib/Collection.php index 986cd33090a..38d3835ff03 100644 --- a/htdocs/includes/stripe/lib/Collection.php +++ b/htdocs/includes/stripe/stripe-php/lib/Collection.php @@ -14,7 +14,6 @@ namespace Stripe; */ class Collection extends StripeObject implements \IteratorAggregate { - const OBJECT_NAME = "list"; use ApiOperations\Request; diff --git a/htdocs/includes/stripe/lib/CountrySpec.php b/htdocs/includes/stripe/stripe-php/lib/CountrySpec.php similarity index 99% rename from htdocs/includes/stripe/lib/CountrySpec.php rename to htdocs/includes/stripe/stripe-php/lib/CountrySpec.php index 668bfe62ed9..ef02c340b5e 100644 --- a/htdocs/includes/stripe/lib/CountrySpec.php +++ b/htdocs/includes/stripe/stripe-php/lib/CountrySpec.php @@ -18,7 +18,6 @@ namespace Stripe; */ class CountrySpec extends ApiResource { - const OBJECT_NAME = "country_spec"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Coupon.php b/htdocs/includes/stripe/stripe-php/lib/Coupon.php similarity index 99% rename from htdocs/includes/stripe/lib/Coupon.php rename to htdocs/includes/stripe/stripe-php/lib/Coupon.php index 51d4fd86593..76d549ad90d 100644 --- a/htdocs/includes/stripe/lib/Coupon.php +++ b/htdocs/includes/stripe/stripe-php/lib/Coupon.php @@ -25,7 +25,6 @@ namespace Stripe; */ class Coupon extends ApiResource { - const OBJECT_NAME = "coupon"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/CreditNote.php b/htdocs/includes/stripe/stripe-php/lib/CreditNote.php similarity index 99% rename from htdocs/includes/stripe/lib/CreditNote.php rename to htdocs/includes/stripe/stripe-php/lib/CreditNote.php index 66351ffb828..c81d86ee66d 100644 --- a/htdocs/includes/stripe/lib/CreditNote.php +++ b/htdocs/includes/stripe/stripe-php/lib/CreditNote.php @@ -27,7 +27,6 @@ namespace Stripe; */ class CreditNote extends ApiResource { - const OBJECT_NAME = "credit_note"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Customer.php b/htdocs/includes/stripe/stripe-php/lib/Customer.php similarity index 99% rename from htdocs/includes/stripe/lib/Customer.php rename to htdocs/includes/stripe/stripe-php/lib/Customer.php index 6e78f981ee4..a3f7f6311da 100644 --- a/htdocs/includes/stripe/lib/Customer.php +++ b/htdocs/includes/stripe/stripe-php/lib/Customer.php @@ -33,7 +33,6 @@ namespace Stripe; */ class Customer extends ApiResource { - const OBJECT_NAME = "customer"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php b/htdocs/includes/stripe/stripe-php/lib/CustomerBalanceTransaction.php similarity index 100% rename from htdocs/includes/stripe/lib/CustomerBalanceTransaction.php rename to htdocs/includes/stripe/stripe-php/lib/CustomerBalanceTransaction.php diff --git a/htdocs/includes/stripe/lib/Discount.php b/htdocs/includes/stripe/stripe-php/lib/Discount.php similarity index 99% rename from htdocs/includes/stripe/lib/Discount.php rename to htdocs/includes/stripe/stripe-php/lib/Discount.php index a72d12bc6e3..68bfc0fd74a 100644 --- a/htdocs/includes/stripe/lib/Discount.php +++ b/htdocs/includes/stripe/stripe-php/lib/Discount.php @@ -16,6 +16,5 @@ namespace Stripe; */ class Discount extends StripeObject { - const OBJECT_NAME = "discount"; } diff --git a/htdocs/includes/stripe/lib/Dispute.php b/htdocs/includes/stripe/stripe-php/lib/Dispute.php similarity index 99% rename from htdocs/includes/stripe/lib/Dispute.php rename to htdocs/includes/stripe/stripe-php/lib/Dispute.php index 2d58daa380a..8ffc2d4cc73 100644 --- a/htdocs/includes/stripe/lib/Dispute.php +++ b/htdocs/includes/stripe/stripe-php/lib/Dispute.php @@ -24,7 +24,6 @@ namespace Stripe; */ class Dispute extends ApiResource { - const OBJECT_NAME = "dispute"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/EphemeralKey.php b/htdocs/includes/stripe/stripe-php/lib/EphemeralKey.php similarity index 99% rename from htdocs/includes/stripe/lib/EphemeralKey.php rename to htdocs/includes/stripe/stripe-php/lib/EphemeralKey.php index 5ed4646b4f7..ea4cc756ccd 100644 --- a/htdocs/includes/stripe/lib/EphemeralKey.php +++ b/htdocs/includes/stripe/stripe-php/lib/EphemeralKey.php @@ -17,7 +17,6 @@ namespace Stripe; */ class EphemeralKey extends ApiResource { - const OBJECT_NAME = "ephemeral_key"; use ApiOperations\Create { diff --git a/htdocs/includes/stripe/lib/Error/Api.php b/htdocs/includes/stripe/stripe-php/lib/Error/Api.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/Api.php rename to htdocs/includes/stripe/stripe-php/lib/Error/Api.php diff --git a/htdocs/includes/stripe/lib/Error/ApiConnection.php b/htdocs/includes/stripe/stripe-php/lib/Error/ApiConnection.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/ApiConnection.php rename to htdocs/includes/stripe/stripe-php/lib/Error/ApiConnection.php diff --git a/htdocs/includes/stripe/lib/Error/Authentication.php b/htdocs/includes/stripe/stripe-php/lib/Error/Authentication.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/Authentication.php rename to htdocs/includes/stripe/stripe-php/lib/Error/Authentication.php diff --git a/htdocs/includes/stripe/lib/Error/Base.php b/htdocs/includes/stripe/stripe-php/lib/Error/Base.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/Base.php rename to htdocs/includes/stripe/stripe-php/lib/Error/Base.php diff --git a/htdocs/includes/stripe/lib/Error/Card.php b/htdocs/includes/stripe/stripe-php/lib/Error/Card.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/Card.php rename to htdocs/includes/stripe/stripe-php/lib/Error/Card.php diff --git a/htdocs/includes/stripe/lib/Error/Idempotency.php b/htdocs/includes/stripe/stripe-php/lib/Error/Idempotency.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/Idempotency.php rename to htdocs/includes/stripe/stripe-php/lib/Error/Idempotency.php diff --git a/htdocs/includes/stripe/lib/Error/InvalidRequest.php b/htdocs/includes/stripe/stripe-php/lib/Error/InvalidRequest.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/InvalidRequest.php rename to htdocs/includes/stripe/stripe-php/lib/Error/InvalidRequest.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/InvalidClient.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidClient.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/InvalidClient.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidClient.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/InvalidGrant.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidGrant.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/InvalidGrant.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidGrant.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/InvalidRequest.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidRequest.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/InvalidRequest.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidRequest.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/InvalidScope.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidScope.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/InvalidScope.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/InvalidScope.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/OAuthBase.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/OAuthBase.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/OAuthBase.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/OAuthBase.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/UnsupportedGrantType.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/UnsupportedGrantType.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/UnsupportedGrantType.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/UnsupportedGrantType.php diff --git a/htdocs/includes/stripe/lib/Error/OAuth/UnsupportedResponseType.php b/htdocs/includes/stripe/stripe-php/lib/Error/OAuth/UnsupportedResponseType.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/OAuth/UnsupportedResponseType.php rename to htdocs/includes/stripe/stripe-php/lib/Error/OAuth/UnsupportedResponseType.php diff --git a/htdocs/includes/stripe/lib/Error/Permission.php b/htdocs/includes/stripe/stripe-php/lib/Error/Permission.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/Permission.php rename to htdocs/includes/stripe/stripe-php/lib/Error/Permission.php diff --git a/htdocs/includes/stripe/lib/Error/RateLimit.php b/htdocs/includes/stripe/stripe-php/lib/Error/RateLimit.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/RateLimit.php rename to htdocs/includes/stripe/stripe-php/lib/Error/RateLimit.php diff --git a/htdocs/includes/stripe/lib/Error/SignatureVerification.php b/htdocs/includes/stripe/stripe-php/lib/Error/SignatureVerification.php similarity index 100% rename from htdocs/includes/stripe/lib/Error/SignatureVerification.php rename to htdocs/includes/stripe/stripe-php/lib/Error/SignatureVerification.php diff --git a/htdocs/includes/stripe/lib/Event.php b/htdocs/includes/stripe/stripe-php/lib/Event.php similarity index 99% rename from htdocs/includes/stripe/lib/Event.php rename to htdocs/includes/stripe/stripe-php/lib/Event.php index a986c35dfec..f9a004aa6a9 100644 --- a/htdocs/includes/stripe/lib/Event.php +++ b/htdocs/includes/stripe/stripe-php/lib/Event.php @@ -20,7 +20,6 @@ namespace Stripe; */ class Event extends ApiResource { - const OBJECT_NAME = "event"; /** diff --git a/htdocs/includes/stripe/lib/ExchangeRate.php b/htdocs/includes/stripe/stripe-php/lib/ExchangeRate.php similarity index 99% rename from htdocs/includes/stripe/lib/ExchangeRate.php rename to htdocs/includes/stripe/stripe-php/lib/ExchangeRate.php index 803a5f87700..6a7e7a36a38 100644 --- a/htdocs/includes/stripe/lib/ExchangeRate.php +++ b/htdocs/includes/stripe/stripe-php/lib/ExchangeRate.php @@ -9,7 +9,6 @@ namespace Stripe; */ class ExchangeRate extends ApiResource { - const OBJECT_NAME = "exchange_rate"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/File.php b/htdocs/includes/stripe/stripe-php/lib/File.php similarity index 100% rename from htdocs/includes/stripe/lib/File.php rename to htdocs/includes/stripe/stripe-php/lib/File.php diff --git a/htdocs/includes/stripe/lib/FileLink.php b/htdocs/includes/stripe/stripe-php/lib/FileLink.php similarity index 99% rename from htdocs/includes/stripe/lib/FileLink.php rename to htdocs/includes/stripe/stripe-php/lib/FileLink.php index 2a012b36105..385971f7d82 100644 --- a/htdocs/includes/stripe/lib/FileLink.php +++ b/htdocs/includes/stripe/stripe-php/lib/FileLink.php @@ -19,7 +19,6 @@ namespace Stripe; */ class FileLink extends ApiResource { - const OBJECT_NAME = "file_link"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/FileUpload.php b/htdocs/includes/stripe/stripe-php/lib/FileUpload.php similarity index 100% rename from htdocs/includes/stripe/lib/FileUpload.php rename to htdocs/includes/stripe/stripe-php/lib/FileUpload.php diff --git a/htdocs/includes/stripe/lib/HttpClient/ClientInterface.php b/htdocs/includes/stripe/stripe-php/lib/HttpClient/ClientInterface.php similarity index 100% rename from htdocs/includes/stripe/lib/HttpClient/ClientInterface.php rename to htdocs/includes/stripe/stripe-php/lib/HttpClient/ClientInterface.php diff --git a/htdocs/includes/stripe/lib/HttpClient/CurlClient.php b/htdocs/includes/stripe/stripe-php/lib/HttpClient/CurlClient.php similarity index 100% rename from htdocs/includes/stripe/lib/HttpClient/CurlClient.php rename to htdocs/includes/stripe/stripe-php/lib/HttpClient/CurlClient.php diff --git a/htdocs/includes/stripe/lib/Invoice.php b/htdocs/includes/stripe/stripe-php/lib/Invoice.php similarity index 99% rename from htdocs/includes/stripe/lib/Invoice.php rename to htdocs/includes/stripe/stripe-php/lib/Invoice.php index 31a84585485..a309dd9e477 100644 --- a/htdocs/includes/stripe/lib/Invoice.php +++ b/htdocs/includes/stripe/stripe-php/lib/Invoice.php @@ -70,7 +70,6 @@ namespace Stripe; */ class Invoice extends ApiResource { - const OBJECT_NAME = "invoice"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/InvoiceItem.php b/htdocs/includes/stripe/stripe-php/lib/InvoiceItem.php similarity index 99% rename from htdocs/includes/stripe/lib/InvoiceItem.php rename to htdocs/includes/stripe/stripe-php/lib/InvoiceItem.php index 02ca0f2d7ee..2f74dabec5c 100644 --- a/htdocs/includes/stripe/lib/InvoiceItem.php +++ b/htdocs/includes/stripe/stripe-php/lib/InvoiceItem.php @@ -29,7 +29,6 @@ namespace Stripe; */ class InvoiceItem extends ApiResource { - const OBJECT_NAME = "invoiceitem"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/InvoiceLineItem.php b/htdocs/includes/stripe/stripe-php/lib/InvoiceLineItem.php similarity index 100% rename from htdocs/includes/stripe/lib/InvoiceLineItem.php rename to htdocs/includes/stripe/stripe-php/lib/InvoiceLineItem.php diff --git a/htdocs/includes/stripe/lib/IssuerFraudRecord.php b/htdocs/includes/stripe/stripe-php/lib/IssuerFraudRecord.php similarity index 99% rename from htdocs/includes/stripe/lib/IssuerFraudRecord.php rename to htdocs/includes/stripe/stripe-php/lib/IssuerFraudRecord.php index 8db4b31b0b4..805dc502885 100644 --- a/htdocs/includes/stripe/lib/IssuerFraudRecord.php +++ b/htdocs/includes/stripe/stripe-php/lib/IssuerFraudRecord.php @@ -17,7 +17,6 @@ namespace Stripe; */ class IssuerFraudRecord extends ApiResource { - const OBJECT_NAME = "issuer_fraud_record"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Issuing/Authorization.php b/htdocs/includes/stripe/stripe-php/lib/Issuing/Authorization.php similarity index 100% rename from htdocs/includes/stripe/lib/Issuing/Authorization.php rename to htdocs/includes/stripe/stripe-php/lib/Issuing/Authorization.php diff --git a/htdocs/includes/stripe/lib/Issuing/Card.php b/htdocs/includes/stripe/stripe-php/lib/Issuing/Card.php similarity index 100% rename from htdocs/includes/stripe/lib/Issuing/Card.php rename to htdocs/includes/stripe/stripe-php/lib/Issuing/Card.php diff --git a/htdocs/includes/stripe/lib/Issuing/CardDetails.php b/htdocs/includes/stripe/stripe-php/lib/Issuing/CardDetails.php similarity index 100% rename from htdocs/includes/stripe/lib/Issuing/CardDetails.php rename to htdocs/includes/stripe/stripe-php/lib/Issuing/CardDetails.php diff --git a/htdocs/includes/stripe/lib/Issuing/Cardholder.php b/htdocs/includes/stripe/stripe-php/lib/Issuing/Cardholder.php similarity index 100% rename from htdocs/includes/stripe/lib/Issuing/Cardholder.php rename to htdocs/includes/stripe/stripe-php/lib/Issuing/Cardholder.php diff --git a/htdocs/includes/stripe/lib/Issuing/Dispute.php b/htdocs/includes/stripe/stripe-php/lib/Issuing/Dispute.php similarity index 100% rename from htdocs/includes/stripe/lib/Issuing/Dispute.php rename to htdocs/includes/stripe/stripe-php/lib/Issuing/Dispute.php diff --git a/htdocs/includes/stripe/lib/Issuing/Transaction.php b/htdocs/includes/stripe/stripe-php/lib/Issuing/Transaction.php similarity index 100% rename from htdocs/includes/stripe/lib/Issuing/Transaction.php rename to htdocs/includes/stripe/stripe-php/lib/Issuing/Transaction.php diff --git a/htdocs/includes/stripe/lib/LoginLink.php b/htdocs/includes/stripe/stripe-php/lib/LoginLink.php similarity index 99% rename from htdocs/includes/stripe/lib/LoginLink.php rename to htdocs/includes/stripe/stripe-php/lib/LoginLink.php index 3a443bf1681..9f677364b17 100644 --- a/htdocs/includes/stripe/lib/LoginLink.php +++ b/htdocs/includes/stripe/stripe-php/lib/LoginLink.php @@ -13,6 +13,5 @@ namespace Stripe; */ class LoginLink extends ApiResource { - const OBJECT_NAME = "login_link"; } diff --git a/htdocs/includes/stripe/lib/OAuth.php b/htdocs/includes/stripe/stripe-php/lib/OAuth.php similarity index 100% rename from htdocs/includes/stripe/lib/OAuth.php rename to htdocs/includes/stripe/stripe-php/lib/OAuth.php diff --git a/htdocs/includes/stripe/lib/Order.php b/htdocs/includes/stripe/stripe-php/lib/Order.php similarity index 99% rename from htdocs/includes/stripe/lib/Order.php rename to htdocs/includes/stripe/stripe-php/lib/Order.php index 0688c6ef937..1f2ce2563ac 100644 --- a/htdocs/includes/stripe/lib/Order.php +++ b/htdocs/includes/stripe/stripe-php/lib/Order.php @@ -33,7 +33,6 @@ namespace Stripe; */ class Order extends ApiResource { - const OBJECT_NAME = "order"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/OrderItem.php b/htdocs/includes/stripe/stripe-php/lib/OrderItem.php similarity index 99% rename from htdocs/includes/stripe/lib/OrderItem.php rename to htdocs/includes/stripe/stripe-php/lib/OrderItem.php index 26d49b4e751..6ef1242fc34 100644 --- a/htdocs/includes/stripe/lib/OrderItem.php +++ b/htdocs/includes/stripe/stripe-php/lib/OrderItem.php @@ -17,6 +17,5 @@ namespace Stripe; */ class OrderItem extends StripeObject { - const OBJECT_NAME = "order_item"; } diff --git a/htdocs/includes/stripe/lib/OrderReturn.php b/htdocs/includes/stripe/stripe-php/lib/OrderReturn.php similarity index 99% rename from htdocs/includes/stripe/lib/OrderReturn.php rename to htdocs/includes/stripe/stripe-php/lib/OrderReturn.php index f3705e86166..3b1ca8efa12 100644 --- a/htdocs/includes/stripe/lib/OrderReturn.php +++ b/htdocs/includes/stripe/stripe-php/lib/OrderReturn.php @@ -19,7 +19,6 @@ namespace Stripe; */ class OrderReturn extends ApiResource { - const OBJECT_NAME = "order_return"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/PaymentIntent.php b/htdocs/includes/stripe/stripe-php/lib/PaymentIntent.php similarity index 99% rename from htdocs/includes/stripe/lib/PaymentIntent.php rename to htdocs/includes/stripe/stripe-php/lib/PaymentIntent.php index 47cbf8fc6cb..b70b1577899 100644 --- a/htdocs/includes/stripe/lib/PaymentIntent.php +++ b/htdocs/includes/stripe/stripe-php/lib/PaymentIntent.php @@ -42,7 +42,6 @@ namespace Stripe; */ class PaymentIntent extends ApiResource { - const OBJECT_NAME = "payment_intent"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/PaymentMethod.php b/htdocs/includes/stripe/stripe-php/lib/PaymentMethod.php similarity index 99% rename from htdocs/includes/stripe/lib/PaymentMethod.php rename to htdocs/includes/stripe/stripe-php/lib/PaymentMethod.php index 1a0bc371d5d..c0557e8c394 100644 --- a/htdocs/includes/stripe/lib/PaymentMethod.php +++ b/htdocs/includes/stripe/stripe-php/lib/PaymentMethod.php @@ -22,7 +22,6 @@ namespace Stripe; */ class PaymentMethod extends ApiResource { - const OBJECT_NAME = "payment_method"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Payout.php b/htdocs/includes/stripe/stripe-php/lib/Payout.php similarity index 99% rename from htdocs/includes/stripe/lib/Payout.php rename to htdocs/includes/stripe/stripe-php/lib/Payout.php index 365d7e47ee9..131bd4ae06d 100644 --- a/htdocs/includes/stripe/lib/Payout.php +++ b/htdocs/includes/stripe/stripe-php/lib/Payout.php @@ -30,7 +30,6 @@ namespace Stripe; */ class Payout extends ApiResource { - const OBJECT_NAME = "payout"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Person.php b/htdocs/includes/stripe/stripe-php/lib/Person.php similarity index 99% rename from htdocs/includes/stripe/lib/Person.php rename to htdocs/includes/stripe/stripe-php/lib/Person.php index f79b80da060..5540f7c5f28 100644 --- a/htdocs/includes/stripe/lib/Person.php +++ b/htdocs/includes/stripe/stripe-php/lib/Person.php @@ -35,7 +35,6 @@ namespace Stripe; */ class Person extends ApiResource { - const OBJECT_NAME = "person"; use ApiOperations\Delete; diff --git a/htdocs/includes/stripe/lib/Plan.php b/htdocs/includes/stripe/stripe-php/lib/Plan.php similarity index 99% rename from htdocs/includes/stripe/lib/Plan.php rename to htdocs/includes/stripe/stripe-php/lib/Plan.php index 54a2b58eb35..1a7ae87dda8 100644 --- a/htdocs/includes/stripe/lib/Plan.php +++ b/htdocs/includes/stripe/stripe-php/lib/Plan.php @@ -29,7 +29,6 @@ namespace Stripe; */ class Plan extends ApiResource { - const OBJECT_NAME = "plan"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Product.php b/htdocs/includes/stripe/stripe-php/lib/Product.php similarity index 99% rename from htdocs/includes/stripe/lib/Product.php rename to htdocs/includes/stripe/stripe-php/lib/Product.php index cb27ef42d8c..6c60d20c4a7 100644 --- a/htdocs/includes/stripe/lib/Product.php +++ b/htdocs/includes/stripe/stripe-php/lib/Product.php @@ -29,7 +29,6 @@ namespace Stripe; */ class Product extends ApiResource { - const OBJECT_NAME = "product"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Radar/EarlyFraudWarning.php b/htdocs/includes/stripe/stripe-php/lib/Radar/EarlyFraudWarning.php similarity index 100% rename from htdocs/includes/stripe/lib/Radar/EarlyFraudWarning.php rename to htdocs/includes/stripe/stripe-php/lib/Radar/EarlyFraudWarning.php diff --git a/htdocs/includes/stripe/lib/Radar/ValueList.php b/htdocs/includes/stripe/stripe-php/lib/Radar/ValueList.php similarity index 100% rename from htdocs/includes/stripe/lib/Radar/ValueList.php rename to htdocs/includes/stripe/stripe-php/lib/Radar/ValueList.php diff --git a/htdocs/includes/stripe/lib/Radar/ValueListItem.php b/htdocs/includes/stripe/stripe-php/lib/Radar/ValueListItem.php similarity index 100% rename from htdocs/includes/stripe/lib/Radar/ValueListItem.php rename to htdocs/includes/stripe/stripe-php/lib/Radar/ValueListItem.php diff --git a/htdocs/includes/stripe/lib/Recipient.php b/htdocs/includes/stripe/stripe-php/lib/Recipient.php similarity index 99% rename from htdocs/includes/stripe/lib/Recipient.php rename to htdocs/includes/stripe/stripe-php/lib/Recipient.php index 2d5eda5cf7f..35a695f5084 100644 --- a/htdocs/includes/stripe/lib/Recipient.php +++ b/htdocs/includes/stripe/stripe-php/lib/Recipient.php @@ -24,7 +24,6 @@ namespace Stripe; */ class Recipient extends ApiResource { - const OBJECT_NAME = "recipient"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/RecipientTransfer.php b/htdocs/includes/stripe/stripe-php/lib/RecipientTransfer.php similarity index 99% rename from htdocs/includes/stripe/lib/RecipientTransfer.php rename to htdocs/includes/stripe/stripe-php/lib/RecipientTransfer.php index 17de5a52e51..7a2ec1f3fb7 100644 --- a/htdocs/includes/stripe/lib/RecipientTransfer.php +++ b/htdocs/includes/stripe/stripe-php/lib/RecipientTransfer.php @@ -34,6 +34,5 @@ namespace Stripe; */ class RecipientTransfer extends ApiResource { - const OBJECT_NAME = "recipient_transfer"; } diff --git a/htdocs/includes/stripe/lib/Refund.php b/htdocs/includes/stripe/stripe-php/lib/Refund.php similarity index 99% rename from htdocs/includes/stripe/lib/Refund.php rename to htdocs/includes/stripe/stripe-php/lib/Refund.php index 6f3fdfaf445..f8b4529b72e 100644 --- a/htdocs/includes/stripe/lib/Refund.php +++ b/htdocs/includes/stripe/stripe-php/lib/Refund.php @@ -26,7 +26,6 @@ namespace Stripe; */ class Refund extends ApiResource { - const OBJECT_NAME = "refund"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Reporting/ReportRun.php b/htdocs/includes/stripe/stripe-php/lib/Reporting/ReportRun.php similarity index 100% rename from htdocs/includes/stripe/lib/Reporting/ReportRun.php rename to htdocs/includes/stripe/stripe-php/lib/Reporting/ReportRun.php diff --git a/htdocs/includes/stripe/lib/Reporting/ReportType.php b/htdocs/includes/stripe/stripe-php/lib/Reporting/ReportType.php similarity index 100% rename from htdocs/includes/stripe/lib/Reporting/ReportType.php rename to htdocs/includes/stripe/stripe-php/lib/Reporting/ReportType.php diff --git a/htdocs/includes/stripe/lib/RequestTelemetry.php b/htdocs/includes/stripe/stripe-php/lib/RequestTelemetry.php similarity index 100% rename from htdocs/includes/stripe/lib/RequestTelemetry.php rename to htdocs/includes/stripe/stripe-php/lib/RequestTelemetry.php diff --git a/htdocs/includes/stripe/lib/Review.php b/htdocs/includes/stripe/stripe-php/lib/Review.php similarity index 100% rename from htdocs/includes/stripe/lib/Review.php rename to htdocs/includes/stripe/stripe-php/lib/Review.php diff --git a/htdocs/includes/stripe/lib/SKU.php b/htdocs/includes/stripe/stripe-php/lib/SKU.php similarity index 99% rename from htdocs/includes/stripe/lib/SKU.php rename to htdocs/includes/stripe/stripe-php/lib/SKU.php index 5b50df8a847..cb3aa6f73f1 100644 --- a/htdocs/includes/stripe/lib/SKU.php +++ b/htdocs/includes/stripe/stripe-php/lib/SKU.php @@ -24,7 +24,6 @@ namespace Stripe; */ class SKU extends ApiResource { - const OBJECT_NAME = "sku"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/SetupIntent.php b/htdocs/includes/stripe/stripe-php/lib/SetupIntent.php similarity index 99% rename from htdocs/includes/stripe/lib/SetupIntent.php rename to htdocs/includes/stripe/stripe-php/lib/SetupIntent.php index f476fb35fa9..176a411b67f 100644 --- a/htdocs/includes/stripe/lib/SetupIntent.php +++ b/htdocs/includes/stripe/stripe-php/lib/SetupIntent.php @@ -25,7 +25,6 @@ namespace Stripe; */ class SetupIntent extends ApiResource { - const OBJECT_NAME = "setup_intent"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Sigma/ScheduledQueryRun.php b/htdocs/includes/stripe/stripe-php/lib/Sigma/ScheduledQueryRun.php similarity index 100% rename from htdocs/includes/stripe/lib/Sigma/ScheduledQueryRun.php rename to htdocs/includes/stripe/stripe-php/lib/Sigma/ScheduledQueryRun.php diff --git a/htdocs/includes/stripe/lib/SingletonApiResource.php b/htdocs/includes/stripe/stripe-php/lib/SingletonApiResource.php similarity index 100% rename from htdocs/includes/stripe/lib/SingletonApiResource.php rename to htdocs/includes/stripe/stripe-php/lib/SingletonApiResource.php diff --git a/htdocs/includes/stripe/lib/Source.php b/htdocs/includes/stripe/stripe-php/lib/Source.php similarity index 99% rename from htdocs/includes/stripe/lib/Source.php rename to htdocs/includes/stripe/stripe-php/lib/Source.php index 1e2c8c73565..ec5cc42127e 100644 --- a/htdocs/includes/stripe/lib/Source.php +++ b/htdocs/includes/stripe/stripe-php/lib/Source.php @@ -43,7 +43,6 @@ namespace Stripe; */ class Source extends ApiResource { - const OBJECT_NAME = "source"; use ApiOperations\Create; diff --git a/htdocs/includes/stripe/lib/SourceTransaction.php b/htdocs/includes/stripe/stripe-php/lib/SourceTransaction.php similarity index 99% rename from htdocs/includes/stripe/lib/SourceTransaction.php rename to htdocs/includes/stripe/stripe-php/lib/SourceTransaction.php index 018a896240e..d004032c569 100644 --- a/htdocs/includes/stripe/lib/SourceTransaction.php +++ b/htdocs/includes/stripe/stripe-php/lib/SourceTransaction.php @@ -18,6 +18,5 @@ namespace Stripe; */ class SourceTransaction extends ApiResource { - const OBJECT_NAME = "source_transaction"; } diff --git a/htdocs/includes/stripe/lib/Stripe.php b/htdocs/includes/stripe/stripe-php/lib/Stripe.php similarity index 99% rename from htdocs/includes/stripe/lib/Stripe.php rename to htdocs/includes/stripe/stripe-php/lib/Stripe.php index 2397ef9c418..0b533e0eb5c 100644 --- a/htdocs/includes/stripe/lib/Stripe.php +++ b/htdocs/includes/stripe/stripe-php/lib/Stripe.php @@ -46,7 +46,7 @@ class Stripe // @var int Maximum number of request retries public static $maxNetworkRetries = 0; - // @var boolean Whether client telemetry is enabled. Defaults to false. + // @var boolean Whether client telemetry is enabled. Defaults to true. public static $enableTelemetry = true; // @var float Maximum delay between retries, in seconds @@ -55,7 +55,7 @@ class Stripe // @var float Initial delay between retries, in seconds private static $initialNetworkRetryDelay = 0.5; - const VERSION = '6.41.0'; + const VERSION = '6.43.1'; /** * @return string The API key used for requests. diff --git a/htdocs/includes/stripe/lib/StripeObject.php b/htdocs/includes/stripe/stripe-php/lib/StripeObject.php similarity index 99% rename from htdocs/includes/stripe/lib/StripeObject.php rename to htdocs/includes/stripe/stripe-php/lib/StripeObject.php index 432e95b7f0b..62e02c0e0cc 100644 --- a/htdocs/includes/stripe/lib/StripeObject.php +++ b/htdocs/includes/stripe/stripe-php/lib/StripeObject.php @@ -153,7 +153,7 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable $nullval = null; if (!empty($this->_values) && array_key_exists($k, $this->_values)) { return $this->_values[$k]; - } else if (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { + } elseif (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { $class = get_class($this); $attrs = join(', ', array_keys($this->_values)); $message = "Stripe Notice: Undefined property of $class instance: $k. " diff --git a/htdocs/includes/stripe/lib/Subscription.php b/htdocs/includes/stripe/stripe-php/lib/Subscription.php similarity index 98% rename from htdocs/includes/stripe/lib/Subscription.php rename to htdocs/includes/stripe/stripe-php/lib/Subscription.php index f5a46171d81..a1087a56a4c 100644 --- a/htdocs/includes/stripe/lib/Subscription.php +++ b/htdocs/includes/stripe/stripe-php/lib/Subscription.php @@ -28,6 +28,7 @@ namespace Stripe; * @property string $latest_invoice * @property boolean $livemode * @property StripeObject $metadata + * @property string $pending_setup_intent * @property Plan $plan * @property int $quantity * @property SubscriptionSchedule $schedule @@ -42,7 +43,6 @@ namespace Stripe; */ class Subscription extends ApiResource { - const OBJECT_NAME = "subscription"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/SubscriptionItem.php b/htdocs/includes/stripe/stripe-php/lib/SubscriptionItem.php similarity index 65% rename from htdocs/includes/stripe/lib/SubscriptionItem.php rename to htdocs/includes/stripe/stripe-php/lib/SubscriptionItem.php index 5baa540fe98..d0d2dea8fcf 100644 --- a/htdocs/includes/stripe/lib/SubscriptionItem.php +++ b/htdocs/includes/stripe/stripe-php/lib/SubscriptionItem.php @@ -19,20 +19,34 @@ namespace Stripe; */ class SubscriptionItem extends ApiResource { - const OBJECT_NAME = "subscription_item"; + const PATH_USAGE_RECORDS = '/usage_records'; + use ApiOperations\All; use ApiOperations\Create; use ApiOperations\Delete; + use ApiOperations\NestedResource; use ApiOperations\Retrieve; use ApiOperations\Update; + /** + * @param string|null $id The ID of the subscription item on which to create the usage record. + * @param array|null $params + * @param array|string|null $opts + * + * @return ApiResource + */ + public static function createUsageRecord($id, $params = null, $opts = null) + { + return self::_createNestedResource($id, static::PATH_USAGE_RECORDS, $params, $opts); + } + /** * @param array|null $params * @param array|string|null $options * - * @return Collection The list of source transactions. + * @return Collection The list of usage record summaries. */ public function usageRecordSummaries($params = null, $options = null) { diff --git a/htdocs/includes/stripe/lib/SubscriptionSchedule.php b/htdocs/includes/stripe/stripe-php/lib/SubscriptionSchedule.php similarity index 56% rename from htdocs/includes/stripe/lib/SubscriptionSchedule.php rename to htdocs/includes/stripe/stripe-php/lib/SubscriptionSchedule.php index ac3686f1db8..e41f279a036 100644 --- a/htdocs/includes/stripe/lib/SubscriptionSchedule.php +++ b/htdocs/includes/stripe/stripe-php/lib/SubscriptionSchedule.php @@ -30,7 +30,6 @@ namespace Stripe; */ class SubscriptionSchedule extends ApiResource { - const OBJECT_NAME = "subscription_schedule"; use ApiOperations\All; @@ -39,8 +38,6 @@ class SubscriptionSchedule extends ApiResource use ApiOperations\Update; use ApiOperations\NestedResource; - const PATH_REVISIONS = '/revisions'; - /** * @param array|null $params * @param array|string|null $opts @@ -68,44 +65,4 @@ class SubscriptionSchedule extends ApiResource $this->refreshFrom($response, $opts); return $this; } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Collection The list of subscription schedule revisions. - */ - public function revisions($params = null, $options = null) - { - $url = $this->instanceUrl() . '/revisions'; - list($response, $opts) = $this->_request('get', $url, $params, $options); - $obj = Util\Util::convertToStripeObject($response, $opts); - $obj->setLastResponse($response); - return $obj; - } - - /** - * @param array|null $id The ID of the subscription schedule to which the person belongs. - * @param array|null $personId The ID of the person to retrieve. - * @param array|null $params - * @param array|string|null $opts - * - * @return Revision - */ - public static function retrieveRevision($id, $personId, $params = null, $opts = null) - { - return self::_retrieveNestedResource($id, static::PATH_REVISIONS, $personId, $params, $opts); - } - - /** - * @param array|null $id The ID of the subscription schedule on which to retrieve the persons. - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection The list of revisions. - */ - public static function allRevisions($id, $params = null, $opts = null) - { - return self::_allNestedResources($id, static::PATH_REVISIONS, $params, $opts); - } } diff --git a/htdocs/includes/stripe/lib/TaxId.php b/htdocs/includes/stripe/stripe-php/lib/TaxId.php similarity index 99% rename from htdocs/includes/stripe/lib/TaxId.php rename to htdocs/includes/stripe/stripe-php/lib/TaxId.php index 0f72a2ac95f..8d607132e6e 100644 --- a/htdocs/includes/stripe/lib/TaxId.php +++ b/htdocs/includes/stripe/stripe-php/lib/TaxId.php @@ -19,7 +19,6 @@ namespace Stripe; */ class TaxId extends ApiResource { - const OBJECT_NAME = "tax_id"; use ApiOperations\Delete; diff --git a/htdocs/includes/stripe/lib/TaxRate.php b/htdocs/includes/stripe/stripe-php/lib/TaxRate.php similarity index 99% rename from htdocs/includes/stripe/lib/TaxRate.php rename to htdocs/includes/stripe/stripe-php/lib/TaxRate.php index 25884dd840f..9f416507cf4 100644 --- a/htdocs/includes/stripe/lib/TaxRate.php +++ b/htdocs/includes/stripe/stripe-php/lib/TaxRate.php @@ -21,7 +21,6 @@ namespace Stripe; */ class TaxRate extends ApiResource { - const OBJECT_NAME = "tax_rate"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Terminal/ConnectionToken.php b/htdocs/includes/stripe/stripe-php/lib/Terminal/ConnectionToken.php similarity index 100% rename from htdocs/includes/stripe/lib/Terminal/ConnectionToken.php rename to htdocs/includes/stripe/stripe-php/lib/Terminal/ConnectionToken.php diff --git a/htdocs/includes/stripe/lib/Terminal/Location.php b/htdocs/includes/stripe/stripe-php/lib/Terminal/Location.php similarity index 100% rename from htdocs/includes/stripe/lib/Terminal/Location.php rename to htdocs/includes/stripe/stripe-php/lib/Terminal/Location.php diff --git a/htdocs/includes/stripe/lib/Terminal/Reader.php b/htdocs/includes/stripe/stripe-php/lib/Terminal/Reader.php similarity index 100% rename from htdocs/includes/stripe/lib/Terminal/Reader.php rename to htdocs/includes/stripe/stripe-php/lib/Terminal/Reader.php diff --git a/htdocs/includes/stripe/lib/ThreeDSecure.php b/htdocs/includes/stripe/stripe-php/lib/ThreeDSecure.php similarity index 99% rename from htdocs/includes/stripe/lib/ThreeDSecure.php rename to htdocs/includes/stripe/stripe-php/lib/ThreeDSecure.php index 5e67e351ba7..3869eba85b3 100644 --- a/htdocs/includes/stripe/lib/ThreeDSecure.php +++ b/htdocs/includes/stripe/stripe-php/lib/ThreeDSecure.php @@ -4,7 +4,6 @@ namespace Stripe; class ThreeDSecure extends ApiResource { - const OBJECT_NAME = "three_d_secure"; use ApiOperations\Create; diff --git a/htdocs/includes/stripe/lib/Token.php b/htdocs/includes/stripe/stripe-php/lib/Token.php similarity index 99% rename from htdocs/includes/stripe/lib/Token.php rename to htdocs/includes/stripe/stripe-php/lib/Token.php index 989219fc789..629d51f6867 100644 --- a/htdocs/includes/stripe/lib/Token.php +++ b/htdocs/includes/stripe/stripe-php/lib/Token.php @@ -19,7 +19,6 @@ namespace Stripe; */ class Token extends ApiResource { - const OBJECT_NAME = "token"; use ApiOperations\Create; diff --git a/htdocs/includes/stripe/lib/Topup.php b/htdocs/includes/stripe/stripe-php/lib/Topup.php similarity index 99% rename from htdocs/includes/stripe/lib/Topup.php rename to htdocs/includes/stripe/stripe-php/lib/Topup.php index 9ad96670a55..37625a329ff 100644 --- a/htdocs/includes/stripe/lib/Topup.php +++ b/htdocs/includes/stripe/stripe-php/lib/Topup.php @@ -26,7 +26,6 @@ namespace Stripe; */ class Topup extends ApiResource { - const OBJECT_NAME = "topup"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/Transfer.php b/htdocs/includes/stripe/stripe-php/lib/Transfer.php similarity index 99% rename from htdocs/includes/stripe/lib/Transfer.php rename to htdocs/includes/stripe/stripe-php/lib/Transfer.php index dff2faa3329..bf9fa25ce37 100644 --- a/htdocs/includes/stripe/lib/Transfer.php +++ b/htdocs/includes/stripe/stripe-php/lib/Transfer.php @@ -27,7 +27,6 @@ namespace Stripe; */ class Transfer extends ApiResource { - const OBJECT_NAME = "transfer"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/TransferReversal.php b/htdocs/includes/stripe/stripe-php/lib/TransferReversal.php similarity index 99% rename from htdocs/includes/stripe/lib/TransferReversal.php rename to htdocs/includes/stripe/stripe-php/lib/TransferReversal.php index c945e5a9360..a4f94f2fb43 100644 --- a/htdocs/includes/stripe/lib/TransferReversal.php +++ b/htdocs/includes/stripe/stripe-php/lib/TransferReversal.php @@ -20,7 +20,6 @@ namespace Stripe; */ class TransferReversal extends ApiResource { - const OBJECT_NAME = "transfer_reversal"; use ApiOperations\Update { diff --git a/htdocs/includes/stripe/lib/UsageRecord.php b/htdocs/includes/stripe/stripe-php/lib/UsageRecord.php similarity index 99% rename from htdocs/includes/stripe/lib/UsageRecord.php rename to htdocs/includes/stripe/stripe-php/lib/UsageRecord.php index a9e3a25e3e9..1239222d49d 100644 --- a/htdocs/includes/stripe/lib/UsageRecord.php +++ b/htdocs/includes/stripe/stripe-php/lib/UsageRecord.php @@ -16,7 +16,6 @@ namespace Stripe; */ class UsageRecord extends ApiResource { - const OBJECT_NAME = "usage_record"; /** diff --git a/htdocs/includes/stripe/lib/UsageRecordSummary.php b/htdocs/includes/stripe/stripe-php/lib/UsageRecordSummary.php similarity index 99% rename from htdocs/includes/stripe/lib/UsageRecordSummary.php rename to htdocs/includes/stripe/stripe-php/lib/UsageRecordSummary.php index b8f4aebe974..9d3e7a396ed 100644 --- a/htdocs/includes/stripe/lib/UsageRecordSummary.php +++ b/htdocs/includes/stripe/stripe-php/lib/UsageRecordSummary.php @@ -17,6 +17,5 @@ namespace Stripe; */ class UsageRecordSummary extends ApiResource { - const OBJECT_NAME = "usage_record_summary"; } diff --git a/htdocs/includes/stripe/lib/Util/AutoPagingIterator.php b/htdocs/includes/stripe/stripe-php/lib/Util/AutoPagingIterator.php similarity index 100% rename from htdocs/includes/stripe/lib/Util/AutoPagingIterator.php rename to htdocs/includes/stripe/stripe-php/lib/Util/AutoPagingIterator.php diff --git a/htdocs/includes/stripe/lib/Util/CaseInsensitiveArray.php b/htdocs/includes/stripe/stripe-php/lib/Util/CaseInsensitiveArray.php similarity index 100% rename from htdocs/includes/stripe/lib/Util/CaseInsensitiveArray.php rename to htdocs/includes/stripe/stripe-php/lib/Util/CaseInsensitiveArray.php diff --git a/htdocs/includes/stripe/lib/Util/DefaultLogger.php b/htdocs/includes/stripe/stripe-php/lib/Util/DefaultLogger.php similarity index 100% rename from htdocs/includes/stripe/lib/Util/DefaultLogger.php rename to htdocs/includes/stripe/stripe-php/lib/Util/DefaultLogger.php diff --git a/htdocs/includes/stripe/lib/Util/LoggerInterface.php b/htdocs/includes/stripe/stripe-php/lib/Util/LoggerInterface.php similarity index 98% rename from htdocs/includes/stripe/lib/Util/LoggerInterface.php rename to htdocs/includes/stripe/stripe-php/lib/Util/LoggerInterface.php index bbdfc929982..cf04e1d2bad 100644 --- a/htdocs/includes/stripe/lib/Util/LoggerInterface.php +++ b/htdocs/includes/stripe/stripe-php/lib/Util/LoggerInterface.php @@ -30,7 +30,7 @@ interface LoggerInterface * * @param string $message * @param array $context - * @return null + * @return void */ public function error($message, array $context = []); } diff --git a/htdocs/includes/stripe/lib/Util/RandomGenerator.php b/htdocs/includes/stripe/stripe-php/lib/Util/RandomGenerator.php similarity index 100% rename from htdocs/includes/stripe/lib/Util/RandomGenerator.php rename to htdocs/includes/stripe/stripe-php/lib/Util/RandomGenerator.php diff --git a/htdocs/includes/stripe/lib/Util/RequestOptions.php b/htdocs/includes/stripe/stripe-php/lib/Util/RequestOptions.php similarity index 100% rename from htdocs/includes/stripe/lib/Util/RequestOptions.php rename to htdocs/includes/stripe/stripe-php/lib/Util/RequestOptions.php diff --git a/htdocs/includes/stripe/lib/Util/Set.php b/htdocs/includes/stripe/stripe-php/lib/Util/Set.php similarity index 100% rename from htdocs/includes/stripe/lib/Util/Set.php rename to htdocs/includes/stripe/stripe-php/lib/Util/Set.php diff --git a/htdocs/includes/stripe/lib/Util/Util.php b/htdocs/includes/stripe/stripe-php/lib/Util/Util.php similarity index 99% rename from htdocs/includes/stripe/lib/Util/Util.php rename to htdocs/includes/stripe/stripe-php/lib/Util/Util.php index f9f15440023..dd8677aa099 100644 --- a/htdocs/includes/stripe/lib/Util/Util.php +++ b/htdocs/includes/stripe/stripe-php/lib/Util/Util.php @@ -135,7 +135,6 @@ abstract class Util \Stripe\Subscription::OBJECT_NAME => 'Stripe\\Subscription', \Stripe\SubscriptionItem::OBJECT_NAME => 'Stripe\\SubscriptionItem', \Stripe\SubscriptionSchedule::OBJECT_NAME => 'Stripe\\SubscriptionSchedule', - \Stripe\SubscriptionScheduleRevision::OBJECT_NAME => 'Stripe\\SubscriptionScheduleRevision', \Stripe\TaxId::OBJECT_NAME => 'Stripe\\TaxId', \Stripe\TaxRate::OBJECT_NAME => 'Stripe\\TaxRate', \Stripe\ThreeDSecure::OBJECT_NAME => 'Stripe\\ThreeDSecure', diff --git a/htdocs/includes/stripe/lib/Webhook.php b/htdocs/includes/stripe/stripe-php/lib/Webhook.php similarity index 100% rename from htdocs/includes/stripe/lib/Webhook.php rename to htdocs/includes/stripe/stripe-php/lib/Webhook.php diff --git a/htdocs/includes/stripe/lib/WebhookEndpoint.php b/htdocs/includes/stripe/stripe-php/lib/WebhookEndpoint.php similarity index 99% rename from htdocs/includes/stripe/lib/WebhookEndpoint.php rename to htdocs/includes/stripe/stripe-php/lib/WebhookEndpoint.php index 27ecacf690c..636c7e1927d 100644 --- a/htdocs/includes/stripe/lib/WebhookEndpoint.php +++ b/htdocs/includes/stripe/stripe-php/lib/WebhookEndpoint.php @@ -18,7 +18,6 @@ namespace Stripe; */ class WebhookEndpoint extends ApiResource { - const OBJECT_NAME = "webhook_endpoint"; use ApiOperations\All; diff --git a/htdocs/includes/stripe/lib/WebhookSignature.php b/htdocs/includes/stripe/stripe-php/lib/WebhookSignature.php similarity index 100% rename from htdocs/includes/stripe/lib/WebhookSignature.php rename to htdocs/includes/stripe/stripe-php/lib/WebhookSignature.php diff --git a/htdocs/includes/stripe/update_certs.php b/htdocs/includes/stripe/stripe-php/update_certs.php old mode 100644 new mode 100755 similarity index 100% rename from htdocs/includes/stripe/update_certs.php rename to htdocs/includes/stripe/stripe-php/update_certs.php diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1f1c1ed40d4..b29ac2400e9 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -195,7 +195,7 @@ if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->payb } if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This include also /stripe/lib/stripe.lib.php, /includes/stripe/init.php, ... + require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This include also /stripe/lib/stripe.lib.php, /includes/stripe/stripe-php/init.php, ... } // Initialize $validpaymentmethod diff --git a/htdocs/public/stripe/confirm_payment.php b/htdocs/public/stripe/confirm_payment.php index 51c2a1bf9a5..7e7dd12fcff 100644 --- a/htdocs/public/stripe/confirm_payment.php +++ b/htdocs/public/stripe/confirm_payment.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; if (empty($conf->stripe->enabled)) accessforbidden('', 0, 0, 1); diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index f634d49ebac..219ad7e487d 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 65d80f9587b..730203245f4 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -25,8 +25,8 @@ * \brief Page to move config in api */ -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/lib/Stripe.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/lib/Stripe.php'; //global $stripe; global $conf; From 29843165ec4cf922788c689a115a0619577cba5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 03:28:13 +0100 Subject: [PATCH 059/833] Use the header and footer of public pages for the payment ok and ko page --- htdocs/public/payment/paymentko.php | 29 ++++++++++++---- htdocs/public/payment/paymentok.php | 51 +++++++++++++++++++---------- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 2c8b23396c7..eac2fdf9f47 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -68,6 +68,7 @@ $suffix = GETPOST("suffix", 'aZ09'); // Detect $paymentmethod $paymentmethod = ''; +$reg = array(); if (preg_match('/PM=([^\.]+)/', $FULLTAG, $reg)) { $paymentmethod = $reg[1]; @@ -203,14 +204,14 @@ if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head = 'dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); // Show ko message print ''."\n"; print '
'."\n"; - // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) $width = 0; // Define logo and logosmall @@ -222,25 +223,39 @@ elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall = $conf->global-> //print ''."\n"; // Define urllogo $urllogo = ''; +$urllogofull = ''; if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); $width = 150; } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$logo); + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); $width = 150; } + // Output html code for logo if ($urllogo) { - print '
'; + print '
'; + print '
'; - print '
'; + print '>'; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; } + +print '

'; + + print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; $key = 'ONLINE_PAYMENT_MESSAGE_KO'; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 4661067b78e..5029d717a10 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -78,6 +78,7 @@ $suffix=GETPOST("suffix", 'aZ09'); // Detect $paymentmethod $paymentmethod=''; +$reg = array(); if (preg_match('/PM=([^\.]+)/', $FULLTAG, $reg)) { $paymentmethod=$reg[1]; @@ -136,45 +137,59 @@ if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head='dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); // Show message print ''."\n"; -print '
'."\n"; +print '
'."\n"; // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) -$width=0; +$width = 0; // Define logo and logosmall -$logosmall=$mysoc->logo_small; -$logo=$mysoc->logo; -$paramlogo='ONLINE_PAYMENT_LOGO_'.$suffix; -if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; -elseif (! empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall=$conf->global->ONLINE_PAYMENT_LOGO; +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo; +elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; //print ''."\n"; // Define urllogo -$urllogo=''; -if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$logosmall); - $width=150; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $width = 150; } -elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$logo); - $width=150; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $width = 150; } + // Output html code for logo if ($urllogo) { - print '
'; + print '
'; + print '
'; - print '
'; + print '>'; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; } +print '

'; + + if (! empty($conf->paypal->enabled)) { if ($paymentmethod == 'paypal') // We call this page only if payment is ok on payment system From db254b70d4d89823b9f65afaeb2024ce1f869133 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 03:39:48 +0100 Subject: [PATCH 060/833] Update doc --- .github/CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 19c076242f8..66267e42b99 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -101,8 +101,9 @@ Long description (Can span accross multiple lines). ### Pull Requests -When submitting a pull request, use same rule as [Commits](#commits) for the message. +Pull Request process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules and process to follow... +When submitting a pull request, use same rule as [Commits](#commits) for the message. If your pull request only contains one commit, GitHub will be smart enough to fill it for you. Otherwise, please be a bit verbose about what you're providing. @@ -111,7 +112,7 @@ Also, some code changes need a prior approbation: * if you want to include a new external library (into htdocs/includes directory), please ask before to the project manager (@eldy) to see if such a library can be accepted. -* if you add a new table, you must first create a page on http://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add can be accepted as you suggest. +* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add can be accepted as you suggest. Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR. From c3347326b21e7d461943989a296ddf224bb0b246 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 03:53:57 +0100 Subject: [PATCH 061/833] Update doc --- .github/CONTRIBUTING.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 66267e42b99..bb9d829dc9e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -101,18 +101,19 @@ Long description (Can span accross multiple lines). ### Pull Requests -Pull Request process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules and process to follow... +Pull Request (PR) process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules to know and +a process to follow to optimize the chance to have PRs merged efficiently... When submitting a pull request, use same rule as [Commits](#commits) for the message. -If your pull request only contains one commit, GitHub will be smart enough to fill it for you. +If your pull request only contains 1 commit, GitHub will be smart enough to fill it for you. Otherwise, please be a bit verbose about what you're providing. -Your Pull Request (PR) must pass the Continuous Integration checks. +Your Pull Request (PR) must pass the Continuous Integration checks and code quality checks. Also, some code changes need a prior approbation: * if you want to include a new external library (into htdocs/includes directory), please ask before to the project manager (@eldy) to see if such a library can be accepted. -* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add can be accepted as you suggest. +* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add is compatible with curent and future works in progress and can be accepted as you suggest. Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR. @@ -121,9 +122,9 @@ If the label of PR start with "WIP" (Work In Progress), it will not be analyzed If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet. -In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the flag ask you. The majority of PR are waiting an action of the developer/author. +In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag ask you. The majority of open PR are waiting an action of the author of the PR. -Statistics on Dolibarr project shows that around 95% of submitted PR are reviewed and tagged. This is one of the most important ratio of answered PR in Open Source world. Don't expect the core team to reach the 100%. With the increasing popularity of Dolibarr, this ratio will probably decrease in future. +Statistics on Dolibarr project shows that around 95% of submitted PR are reviewed and tagged. Average answer delay is also one of the best among Open source project (just few days before having the Answer Tag set). This is one of the most important ratio of answered PR in Open Source world for a major project. Don't expect the core team to reach the 100%. A so high ratio is very rare on a so popular project and with the increasing popularity of Dolibarr, this ratio will probably decrease in future to a more common level. ### Resources From 9bb8143696f0e8bea3bf4effed763d5ee1deb348 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 03:59:58 +0100 Subject: [PATCH 062/833] Doc --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bb9d829dc9e..14f3e156e97 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -115,7 +115,7 @@ Also, some code changes need a prior approbation: * if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add is compatible with curent and future works in progress and can be accepted as you suggest. -Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR. +Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR (A label is added in such a case). If the label of PR start with "WIP" (Work In Progress), it will not be analyzed (until you change the label of PR). From 280d77a0d6348065e34cf37f37eae68f5b1ab03a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 04:01:47 +0100 Subject: [PATCH 063/833] Typo --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 14f3e156e97..5e56ac2a1fc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -113,7 +113,7 @@ Also, some code changes need a prior approbation: * if you want to include a new external library (into htdocs/includes directory), please ask before to the project manager (@eldy) to see if such a library can be accepted. -* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add is compatible with curent and future works in progress and can be accepted as you suggest. +* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Then ask the project manager (@eldy) if the new data model you plan to add is compatible with curent and future works in progress and can be accepted as you suggest. Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR (A label is added in such a case). From 6dda972ff51c1e53d477042a7ab53b316da141ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 04:12:42 +0100 Subject: [PATCH 064/833] Doxygen --- htdocs/core/class/evalmath.class.php | 253 +++++++++++++++++---------- 1 file changed, 161 insertions(+), 92 deletions(-) diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index 9d970aed789..536ecf2f271 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -1,100 +1,110 @@ + * + * ================================================================================ + * + * NAME + * EvalMath - safely evaluate math expressions + * + * SYNOPSIS + * include('evalmath.class.php'); + * $m = new EvalMath; + * // basic evaluation: + * $result = $m->evaluate('2+2'); + * // supports: order of operation; parentheses; negation; built-in functions + * $result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8'); + * // create your own variables + * $m->evaluate('a = e^(ln(pi))'); + * // or functions + * $m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1'); + * // and then use them + * $result = $m->evaluate('3*f(42,a)'); + * + * DESCRIPTION + * Use the EvalMath class when you want to evaluate mathematical expressions + * from untrusted sources. You can define your own variables and functions, + * which are stored in the object. Try it, it's fun! + * + * METHODS + * $m->evalute($expr) + * Evaluates the expression and returns the result. If an error occurs, + * prints a warning and returns false. If $expr is a function assignment, + * returns true on success. + * + * $m->e($expr) + * A synonym for $m->evaluate(). + * + * $m->vars() + * Returns an associative array of all user-defined variables and values. + * + * $m->funcs() + * Returns an array of all user-defined functions. + * + * PARAMETERS + * $m->suppress_errors + * Set to true to turn off warnings when evaluating expressions + * + * $m->last_error + * If the last evaluation failed, contains a string describing the error. + * (Useful when suppress_errors is on). + * + * $m->last_error_code + * If the last evaluation failed, 2 element array with numeric code and extra info + * + * AUTHOR INFORMATION + * Copyright 2005, Miles Kaufmann. + * + * LICENSE + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1 Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ -EvalMath - PHP Class to safely evaluate math expressions -Copyright (C) 2005 Miles Kaufmann +/** + * \file core/class/evalmath.class.php + * \ingroup core + * \brief This file for Math evaluation + */ -================================================================================ - -NAME - EvalMath - safely evaluate math expressions - -SYNOPSIS - include('evalmath.class.php'); - $m = new EvalMath; - // basic evaluation: - $result = $m->evaluate('2+2'); - // supports: order of operation; parentheses; negation; built-in functions - $result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8'); - // create your own variables - $m->evaluate('a = e^(ln(pi))'); - // or functions - $m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1'); - // and then use them - $result = $m->evaluate('3*f(42,a)'); - -DESCRIPTION - Use the EvalMath class when you want to evaluate mathematical expressions - from untrusted sources. You can define your own variables and functions, - which are stored in the object. Try it, it's fun! - -METHODS - $m->evalute($expr) - Evaluates the expression and returns the result. If an error occurs, - prints a warning and returns false. If $expr is a function assignment, - returns true on success. - - $m->e($expr) - A synonym for $m->evaluate(). - - $m->vars() - Returns an associative array of all user-defined variables and values. - - $m->funcs() - Returns an array of all user-defined functions. - -PARAMETERS - $m->suppress_errors - Set to true to turn off warnings when evaluating expressions - - $m->last_error - If the last evaluation failed, contains a string describing the error. - (Useful when suppress_errors is on). - - $m->last_error_code - If the last evaluation failed, 2 element array with numeric code and extra info - -AUTHOR INFORMATION - Copyright 2005, Miles Kaufmann. - -LICENSE - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1 Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ +/** + * Class EvalMath + */ class EvalMath { - var $suppress_errors = false; - var $last_error = null; - var $last_error_code = null; + public $suppress_errors = false; + public $last_error = null; + public $last_error_code = null; - var $v = array('e'=>2.71,'pi'=>3.14159); // variables (and constants) - var $f = array(); // user-defined functions - var $vb = array('e', 'pi'); // constants - var $fb = array( // built-in functions + public $v = array('e'=>2.71,'pi'=>3.14159); // variables (and constants) + public $f = array(); // user-defined functions + public $vb = array('e', 'pi'); // constants + public $fb = array( // built-in functions 'sin','sinh','arcsin','asin','arcsinh','asinh', 'cos','cosh','arccos','acos','arccosh','acosh', 'tan','tanh','arctan','atan','arctanh','atanh', @@ -109,10 +119,22 @@ class EvalMath $this->v['e'] = exp(1); } + /** + * Evaluate + * + * @param string $expr String + * @return boolean|number|NULL|mixed Result + */ function e($expr) { return $this->evaluate($expr); } + /** + * Evaluate + * + * @param string $expr String + * @return boolean|number|NULL|mixed Result + */ function evaluate($expr) { $this->last_error = null; $this->last_error_code = null; @@ -155,6 +177,11 @@ class EvalMath } } + /** + * vars + * + * @return string Output + */ function vars() { $output = $this->v; unset($output['pi']); @@ -162,6 +189,11 @@ class EvalMath return $output; } + /** + * vars + * + * @return string Output + */ function funcs() { $output = array(); foreach ($this->f as $fnn=>$dat) @@ -169,9 +201,15 @@ class EvalMath return $output; } + //===================== HERE BE INTERNAL METHODS ====================\\ - // Convert infix to postfix notation + /** + * Convert infix to postfix notation + * + * @param string $expr Expression + * @return string Output + */ function nfx($expr) { $index = 0; @@ -297,7 +335,14 @@ class EvalMath return $output; } - // evaluate postfix notation + + /** + * evaluate postfix notation + * + * @param string $tokens Expression + * @param array $vars Array + * @return string Output + */ function pfx($tokens, $vars = array()) { if ($tokens == false) return false; @@ -359,7 +404,14 @@ class EvalMath return $stack->pop(); } - // trigger an error, but nicely, if need be + /** + * trigger an error, but nicely, if need be + * + * @param string $code Code + * @param string $msg Msg + * @param string|null $info sting + * @return boolean False + */ function trigger($code, $msg, $info = null) { $this->last_error = $msg; $this->last_error_code = array($code, $info); @@ -376,11 +428,22 @@ class EvalMathStack var $stack = array(); var $count = 0; + /** + * push + * + * @param string $val Val + * @return void + */ function push($val) { $this->stack[$this->count] = $val; $this->count++; } + /** + * pop + * + * @return mixed Stack + */ function pop() { if ($this->count > 0) { $this->count--; @@ -389,6 +452,12 @@ class EvalMathStack return null; } + /** + * last + * + * @param int $n N + * @return mixed Stack + */ function last($n=1) { if (isset($this->stack[$this->count-$n])) { return $this->stack[$this->count-$n]; From 826ed679217e8da3fe5ea9deb48eae00b5b89c5d Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 13 Mar 2020 09:01:22 +0100 Subject: [PATCH 065/833] FIX travis errors sql escape --- htdocs/core/modules/takepos/mod_takepos_ref_simple.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index f63acb7f7e4..4275e202f6e 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -92,7 +92,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos $posindice = 8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture"; - $sql .= " WHERE ref LIKE '" . $this->prefix . "____-%'"; + $sql .= " WHERE ref LIKE '" . $db->escape($this->prefix) . "____-%'"; $sql .= " AND entity = " . $conf->entity; $resql = $db->query($sql); @@ -131,7 +131,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos $posindice = strlen($this->prefix . $pos_source . '-____-') + 1; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max"; // This is standard SQL $sql .= " FROM " . MAIN_DB_PREFIX . "facture"; - $sql .= " WHERE ref LIKE '" . $this->prefix . $pos_source . "-____-%'"; + $sql .= " WHERE ref LIKE '" . $db->escape($this->prefix . $pos_source) . "-____-%'"; $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; $resql = $db->query($sql); @@ -152,7 +152,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos $ref = ''; $sql = "SELECT ref as ref"; $sql .= " FROM ". MAIN_DB_PREFIX . "facture"; - $sql .= " WHERE ref LIKE '" . $this->prefix . $pos_source . "-____-" . $num . "'"; + $sql .= " WHERE ref LIKE '" . $db->escape($this->prefix . $pos_source) . "-____-" . $num . "'"; $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; $sql .= " ORDER BY ref DESC"; From 68f14ef48322b4a76082f5f5af296e89f7593cf1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 09:37:26 +0100 Subject: [PATCH 066/833] Fix missing js --- htdocs/includes/nnnick/chartjs/.gitignore | 1 - .../nnnick/chartjs/dist/Chart.bundle.js | 20755 ++++++++++++++++ .../nnnick/chartjs/dist/Chart.bundle.min.js | 7 + htdocs/includes/nnnick/chartjs/dist/Chart.css | 47 + htdocs/includes/nnnick/chartjs/dist/Chart.js | 16151 ++++++++++++ .../nnnick/chartjs/dist/Chart.min.css | 1 + .../includes/nnnick/chartjs/dist/Chart.min.js | 7 + 7 files changed, 36968 insertions(+), 1 deletion(-) create mode 100644 htdocs/includes/nnnick/chartjs/dist/Chart.bundle.js create mode 100644 htdocs/includes/nnnick/chartjs/dist/Chart.bundle.min.js create mode 100644 htdocs/includes/nnnick/chartjs/dist/Chart.css create mode 100644 htdocs/includes/nnnick/chartjs/dist/Chart.js create mode 100644 htdocs/includes/nnnick/chartjs/dist/Chart.min.css create mode 100644 htdocs/includes/nnnick/chartjs/dist/Chart.min.js diff --git a/htdocs/includes/nnnick/chartjs/.gitignore b/htdocs/includes/nnnick/chartjs/.gitignore index 6a066b92f38..c4998047b01 100644 --- a/htdocs/includes/nnnick/chartjs/.gitignore +++ b/htdocs/includes/nnnick/chartjs/.gitignore @@ -1,7 +1,6 @@ /_book /coverage /custom -/dist /docs/index.md /gh-pages /jsdoc diff --git a/htdocs/includes/nnnick/chartjs/dist/Chart.bundle.js b/htdocs/includes/nnnick/chartjs/dist/Chart.bundle.js new file mode 100644 index 00000000000..204156a8fc7 --- /dev/null +++ b/htdocs/includes/nnnick/chartjs/dist/Chart.bundle.js @@ -0,0 +1,20755 @@ +/*! + * Chart.js v2.9.3 + * https://www.chartjs.org + * (c) 2019 Chart.js Contributors + * Released under the MIT License + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = global || self, global.Chart = factory()); +}(this, (function () { 'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs'); +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +function getCjsExportFromNamespace (n) { + return n && n['default'] || n; +} + +var colorName = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; + +var conversions = createCommonjsModule(function (module) { +/* MIT license */ + + +// NOTE: conversions should only return primitive values (i.e. arrays, or +// values that give correct `typeof` results). +// do not use box values types (i.e. Number(), String(), etc.) + +var reverseKeywords = {}; +for (var key in colorName) { + if (colorName.hasOwnProperty(key)) { + reverseKeywords[colorName[key]] = key; + } +} + +var convert = module.exports = { + rgb: {channels: 3, labels: 'rgb'}, + hsl: {channels: 3, labels: 'hsl'}, + hsv: {channels: 3, labels: 'hsv'}, + hwb: {channels: 3, labels: 'hwb'}, + cmyk: {channels: 4, labels: 'cmyk'}, + xyz: {channels: 3, labels: 'xyz'}, + lab: {channels: 3, labels: 'lab'}, + lch: {channels: 3, labels: 'lch'}, + hex: {channels: 1, labels: ['hex']}, + keyword: {channels: 1, labels: ['keyword']}, + ansi16: {channels: 1, labels: ['ansi16']}, + ansi256: {channels: 1, labels: ['ansi256']}, + hcg: {channels: 3, labels: ['h', 'c', 'g']}, + apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, + gray: {channels: 1, labels: ['gray']} +}; + +// hide .channels and .labels properties +for (var model in convert) { + if (convert.hasOwnProperty(model)) { + if (!('channels' in convert[model])) { + throw new Error('missing channels property: ' + model); + } + + if (!('labels' in convert[model])) { + throw new Error('missing channel labels property: ' + model); + } + + if (convert[model].labels.length !== convert[model].channels) { + throw new Error('channel and label counts mismatch: ' + model); + } + + var channels = convert[model].channels; + var labels = convert[model].labels; + delete convert[model].channels; + delete convert[model].labels; + Object.defineProperty(convert[model], 'channels', {value: channels}); + Object.defineProperty(convert[model], 'labels', {value: labels}); + } +} + +convert.rgb.hsl = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var delta = max - min; + var h; + var s; + var l; + + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } + + h = Math.min(h * 60, 360); + + if (h < 0) { + h += 360; + } + + l = (min + max) / 2; + + if (max === min) { + s = 0; + } else if (l <= 0.5) { + s = delta / (max + min); + } else { + s = delta / (2 - max - min); + } + + return [h, s * 100, l * 100]; +}; + +convert.rgb.hsv = function (rgb) { + var rdif; + var gdif; + var bdif; + var h; + var s; + + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var v = Math.max(r, g, b); + var diff = v - Math.min(r, g, b); + var diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2; + }; + + if (diff === 0) { + h = s = 0; + } else { + s = diff / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); + + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = (1 / 3) + rdif - bdif; + } else if (b === v) { + h = (2 / 3) + gdif - rdif; + } + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } + } + + return [ + h * 360, + s * 100, + v * 100 + ]; +}; + +convert.rgb.hwb = function (rgb) { + var r = rgb[0]; + var g = rgb[1]; + var b = rgb[2]; + var h = convert.rgb.hsl(rgb)[0]; + var w = 1 / 255 * Math.min(r, Math.min(g, b)); + + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); + + return [h, w * 100, b * 100]; +}; + +convert.rgb.cmyk = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var c; + var m; + var y; + var k; + + k = Math.min(1 - r, 1 - g, 1 - b); + c = (1 - r - k) / (1 - k) || 0; + m = (1 - g - k) / (1 - k) || 0; + y = (1 - b - k) / (1 - k) || 0; + + return [c * 100, m * 100, y * 100, k * 100]; +}; + +/** + * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance + * */ +function comparativeDistance(x, y) { + return ( + Math.pow(x[0] - y[0], 2) + + Math.pow(x[1] - y[1], 2) + + Math.pow(x[2] - y[2], 2) + ); +} + +convert.rgb.keyword = function (rgb) { + var reversed = reverseKeywords[rgb]; + if (reversed) { + return reversed; + } + + var currentClosestDistance = Infinity; + var currentClosestKeyword; + + for (var keyword in colorName) { + if (colorName.hasOwnProperty(keyword)) { + var value = colorName[keyword]; + + // Compute comparative distance + var distance = comparativeDistance(rgb, value); + + // Check if its less, if so set as closest + if (distance < currentClosestDistance) { + currentClosestDistance = distance; + currentClosestKeyword = keyword; + } + } + } + + return currentClosestKeyword; +}; + +convert.keyword.rgb = function (keyword) { + return colorName[keyword]; +}; + +convert.rgb.xyz = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + + // assume sRGB + r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); + g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); + b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); + + var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); + var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); + var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); + + return [x * 100, y * 100, z * 100]; +}; + +convert.rgb.lab = function (rgb) { + var xyz = convert.rgb.xyz(rgb); + var x = xyz[0]; + var y = xyz[1]; + var z = xyz[2]; + var l; + var a; + var b; + + x /= 95.047; + y /= 100; + z /= 108.883; + + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); + + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); + + return [l, a, b]; +}; + +convert.hsl.rgb = function (hsl) { + var h = hsl[0] / 360; + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var t1; + var t2; + var t3; + var rgb; + var val; + + if (s === 0) { + val = l * 255; + return [val, val, val]; + } + + if (l < 0.5) { + t2 = l * (1 + s); + } else { + t2 = l + s - l * s; + } + + t1 = 2 * l - t2; + + rgb = [0, 0, 0]; + for (var i = 0; i < 3; i++) { + t3 = h + 1 / 3 * -(i - 1); + if (t3 < 0) { + t3++; + } + if (t3 > 1) { + t3--; + } + + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3; + } else if (2 * t3 < 1) { + val = t2; + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + } else { + val = t1; + } + + rgb[i] = val * 255; + } + + return rgb; +}; + +convert.hsl.hsv = function (hsl) { + var h = hsl[0]; + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var smin = s; + var lmin = Math.max(l, 0.01); + var sv; + var v; + + l *= 2; + s *= (l <= 1) ? l : 2 - l; + smin *= lmin <= 1 ? lmin : 2 - lmin; + v = (l + s) / 2; + sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); + + return [h, sv * 100, v * 100]; +}; + +convert.hsv.rgb = function (hsv) { + var h = hsv[0] / 60; + var s = hsv[1] / 100; + var v = hsv[2] / 100; + var hi = Math.floor(h) % 6; + + var f = h - Math.floor(h); + var p = 255 * v * (1 - s); + var q = 255 * v * (1 - (s * f)); + var t = 255 * v * (1 - (s * (1 - f))); + v *= 255; + + switch (hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; + } +}; + +convert.hsv.hsl = function (hsv) { + var h = hsv[0]; + var s = hsv[1] / 100; + var v = hsv[2] / 100; + var vmin = Math.max(v, 0.01); + var lmin; + var sl; + var l; + + l = (2 - s) * v; + lmin = (2 - s) * vmin; + sl = s * vmin; + sl /= (lmin <= 1) ? lmin : 2 - lmin; + sl = sl || 0; + l /= 2; + + return [h, sl * 100, l * 100]; +}; + +// http://dev.w3.org/csswg/css-color/#hwb-to-rgb +convert.hwb.rgb = function (hwb) { + var h = hwb[0] / 360; + var wh = hwb[1] / 100; + var bl = hwb[2] / 100; + var ratio = wh + bl; + var i; + var v; + var f; + var n; + + // wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio; + bl /= ratio; + } + + i = Math.floor(6 * h); + v = 1 - bl; + f = 6 * h - i; + + if ((i & 0x01) !== 0) { + f = 1 - f; + } + + n = wh + f * (v - wh); // linear interpolation + + var r; + var g; + var b; + switch (i) { + default: + case 6: + case 0: r = v; g = n; b = wh; break; + case 1: r = n; g = v; b = wh; break; + case 2: r = wh; g = v; b = n; break; + case 3: r = wh; g = n; b = v; break; + case 4: r = n; g = wh; b = v; break; + case 5: r = v; g = wh; b = n; break; + } + + return [r * 255, g * 255, b * 255]; +}; + +convert.cmyk.rgb = function (cmyk) { + var c = cmyk[0] / 100; + var m = cmyk[1] / 100; + var y = cmyk[2] / 100; + var k = cmyk[3] / 100; + var r; + var g; + var b; + + r = 1 - Math.min(1, c * (1 - k) + k); + g = 1 - Math.min(1, m * (1 - k) + k); + b = 1 - Math.min(1, y * (1 - k) + k); + + return [r * 255, g * 255, b * 255]; +}; + +convert.xyz.rgb = function (xyz) { + var x = xyz[0] / 100; + var y = xyz[1] / 100; + var z = xyz[2] / 100; + var r; + var g; + var b; + + r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); + g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); + b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); + + // assume sRGB + r = r > 0.0031308 + ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) + : r * 12.92; + + g = g > 0.0031308 + ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) + : g * 12.92; + + b = b > 0.0031308 + ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) + : b * 12.92; + + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); + + return [r * 255, g * 255, b * 255]; +}; + +convert.xyz.lab = function (xyz) { + var x = xyz[0]; + var y = xyz[1]; + var z = xyz[2]; + var l; + var a; + var b; + + x /= 95.047; + y /= 100; + z /= 108.883; + + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); + + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); + + return [l, a, b]; +}; + +convert.lab.xyz = function (lab) { + var l = lab[0]; + var a = lab[1]; + var b = lab[2]; + var x; + var y; + var z; + + y = (l + 16) / 116; + x = a / 500 + y; + z = y - b / 200; + + var y2 = Math.pow(y, 3); + var x2 = Math.pow(x, 3); + var z2 = Math.pow(z, 3); + y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; + x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; + z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; + + x *= 95.047; + y *= 100; + z *= 108.883; + + return [x, y, z]; +}; + +convert.lab.lch = function (lab) { + var l = lab[0]; + var a = lab[1]; + var b = lab[2]; + var hr; + var h; + var c; + + hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; + + if (h < 0) { + h += 360; + } + + c = Math.sqrt(a * a + b * b); + + return [l, c, h]; +}; + +convert.lch.lab = function (lch) { + var l = lch[0]; + var c = lch[1]; + var h = lch[2]; + var a; + var b; + var hr; + + hr = h / 360 * 2 * Math.PI; + a = c * Math.cos(hr); + b = c * Math.sin(hr); + + return [l, a, b]; +}; + +convert.rgb.ansi16 = function (args) { + var r = args[0]; + var g = args[1]; + var b = args[2]; + var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization + + value = Math.round(value / 50); + + if (value === 0) { + return 30; + } + + var ansi = 30 + + ((Math.round(b / 255) << 2) + | (Math.round(g / 255) << 1) + | Math.round(r / 255)); + + if (value === 2) { + ansi += 60; + } + + return ansi; +}; + +convert.hsv.ansi16 = function (args) { + // optimization here; we already know the value and don't need to get + // it converted for us. + return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); +}; + +convert.rgb.ansi256 = function (args) { + var r = args[0]; + var g = args[1]; + var b = args[2]; + + // we use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r === g && g === b) { + if (r < 8) { + return 16; + } + + if (r > 248) { + return 231; + } + + return Math.round(((r - 8) / 247) * 24) + 232; + } + + var ansi = 16 + + (36 * Math.round(r / 255 * 5)) + + (6 * Math.round(g / 255 * 5)) + + Math.round(b / 255 * 5); + + return ansi; +}; + +convert.ansi16.rgb = function (args) { + var color = args % 10; + + // handle greyscale + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5; + } + + color = color / 10.5 * 255; + + return [color, color, color]; + } + + var mult = (~~(args > 50) + 1) * 0.5; + var r = ((color & 1) * mult) * 255; + var g = (((color >> 1) & 1) * mult) * 255; + var b = (((color >> 2) & 1) * mult) * 255; + + return [r, g, b]; +}; + +convert.ansi256.rgb = function (args) { + // handle greyscale + if (args >= 232) { + var c = (args - 232) * 10 + 8; + return [c, c, c]; + } + + args -= 16; + + var rem; + var r = Math.floor(args / 36) / 5 * 255; + var g = Math.floor((rem = args % 36) / 6) / 5 * 255; + var b = (rem % 6) / 5 * 255; + + return [r, g, b]; +}; + +convert.rgb.hex = function (args) { + var integer = ((Math.round(args[0]) & 0xFF) << 16) + + ((Math.round(args[1]) & 0xFF) << 8) + + (Math.round(args[2]) & 0xFF); + + var string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; + +convert.hex.rgb = function (args) { + var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); + if (!match) { + return [0, 0, 0]; + } + + var colorString = match[0]; + + if (match[0].length === 3) { + colorString = colorString.split('').map(function (char) { + return char + char; + }).join(''); + } + + var integer = parseInt(colorString, 16); + var r = (integer >> 16) & 0xFF; + var g = (integer >> 8) & 0xFF; + var b = integer & 0xFF; + + return [r, g, b]; +}; + +convert.rgb.hcg = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var max = Math.max(Math.max(r, g), b); + var min = Math.min(Math.min(r, g), b); + var chroma = (max - min); + var grayscale; + var hue; + + if (chroma < 1) { + grayscale = min / (1 - chroma); + } else { + grayscale = 0; + } + + if (chroma <= 0) { + hue = 0; + } else + if (max === r) { + hue = ((g - b) / chroma) % 6; + } else + if (max === g) { + hue = 2 + (b - r) / chroma; + } else { + hue = 4 + (r - g) / chroma + 4; + } + + hue /= 6; + hue %= 1; + + return [hue * 360, chroma * 100, grayscale * 100]; +}; + +convert.hsl.hcg = function (hsl) { + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var c = 1; + var f = 0; + + if (l < 0.5) { + c = 2.0 * s * l; + } else { + c = 2.0 * s * (1.0 - l); + } + + if (c < 1.0) { + f = (l - 0.5 * c) / (1.0 - c); + } + + return [hsl[0], c * 100, f * 100]; +}; + +convert.hsv.hcg = function (hsv) { + var s = hsv[1] / 100; + var v = hsv[2] / 100; + + var c = s * v; + var f = 0; + + if (c < 1.0) { + f = (v - c) / (1 - c); + } + + return [hsv[0], c * 100, f * 100]; +}; + +convert.hcg.rgb = function (hcg) { + var h = hcg[0] / 360; + var c = hcg[1] / 100; + var g = hcg[2] / 100; + + if (c === 0.0) { + return [g * 255, g * 255, g * 255]; + } + + var pure = [0, 0, 0]; + var hi = (h % 1) * 6; + var v = hi % 1; + var w = 1 - v; + var mg = 0; + + switch (Math.floor(hi)) { + case 0: + pure[0] = 1; pure[1] = v; pure[2] = 0; break; + case 1: + pure[0] = w; pure[1] = 1; pure[2] = 0; break; + case 2: + pure[0] = 0; pure[1] = 1; pure[2] = v; break; + case 3: + pure[0] = 0; pure[1] = w; pure[2] = 1; break; + case 4: + pure[0] = v; pure[1] = 0; pure[2] = 1; break; + default: + pure[0] = 1; pure[1] = 0; pure[2] = w; + } + + mg = (1.0 - c) * g; + + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ]; +}; + +convert.hcg.hsv = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + + var v = c + g * (1.0 - c); + var f = 0; + + if (v > 0.0) { + f = c / v; + } + + return [hcg[0], f * 100, v * 100]; +}; + +convert.hcg.hsl = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + + var l = g * (1.0 - c) + 0.5 * c; + var s = 0; + + if (l > 0.0 && l < 0.5) { + s = c / (2 * l); + } else + if (l >= 0.5 && l < 1.0) { + s = c / (2 * (1 - l)); + } + + return [hcg[0], s * 100, l * 100]; +}; + +convert.hcg.hwb = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + var v = c + g * (1.0 - c); + return [hcg[0], (v - c) * 100, (1 - v) * 100]; +}; + +convert.hwb.hcg = function (hwb) { + var w = hwb[1] / 100; + var b = hwb[2] / 100; + var v = 1 - b; + var c = v - w; + var g = 0; + + if (c < 1) { + g = (v - c) / (1 - c); + } + + return [hwb[0], c * 100, g * 100]; +}; + +convert.apple.rgb = function (apple) { + return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; +}; + +convert.rgb.apple = function (rgb) { + return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; +}; + +convert.gray.rgb = function (args) { + return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; +}; + +convert.gray.hsl = convert.gray.hsv = function (args) { + return [0, 0, args[0]]; +}; + +convert.gray.hwb = function (gray) { + return [0, 100, gray[0]]; +}; + +convert.gray.cmyk = function (gray) { + return [0, 0, 0, gray[0]]; +}; + +convert.gray.lab = function (gray) { + return [gray[0], 0, 0]; +}; + +convert.gray.hex = function (gray) { + var val = Math.round(gray[0] / 100 * 255) & 0xFF; + var integer = (val << 16) + (val << 8) + val; + + var string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; + +convert.rgb.gray = function (rgb) { + var val = (rgb[0] + rgb[1] + rgb[2]) / 3; + return [val / 255 * 100]; +}; +}); +var conversions_1 = conversions.rgb; +var conversions_2 = conversions.hsl; +var conversions_3 = conversions.hsv; +var conversions_4 = conversions.hwb; +var conversions_5 = conversions.cmyk; +var conversions_6 = conversions.xyz; +var conversions_7 = conversions.lab; +var conversions_8 = conversions.lch; +var conversions_9 = conversions.hex; +var conversions_10 = conversions.keyword; +var conversions_11 = conversions.ansi16; +var conversions_12 = conversions.ansi256; +var conversions_13 = conversions.hcg; +var conversions_14 = conversions.apple; +var conversions_15 = conversions.gray; + +/* + this function routes a model to all other models. + + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). + + conversions that are not possible simply are not included. +*/ + +function buildGraph() { + var graph = {}; + // https://jsperf.com/object-keys-vs-for-in-with-closure/3 + var models = Object.keys(conversions); + + for (var len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } + + return graph; +} + +// https://en.wikipedia.org/wiki/Breadth-first_search +function deriveBFS(fromModel) { + var graph = buildGraph(); + var queue = [fromModel]; // unshift -> queue -> pop + + graph[fromModel].distance = 0; + + while (queue.length) { + var current = queue.pop(); + var adjacents = Object.keys(conversions[current]); + + for (var len = adjacents.length, i = 0; i < len; i++) { + var adjacent = adjacents[i]; + var node = graph[adjacent]; + + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } + + return graph; +} + +function link(from, to) { + return function (args) { + return to(from(args)); + }; +} + +function wrapConversion(toModel, graph) { + var path = [graph[toModel].parent, toModel]; + var fn = conversions[graph[toModel].parent][toModel]; + + var cur = graph[toModel].parent; + while (graph[cur].parent) { + path.unshift(graph[cur].parent); + fn = link(conversions[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } + + fn.conversion = path; + return fn; +} + +var route = function (fromModel) { + var graph = deriveBFS(fromModel); + var conversion = {}; + + var models = Object.keys(graph); + for (var len = models.length, i = 0; i < len; i++) { + var toModel = models[i]; + var node = graph[toModel]; + + if (node.parent === null) { + // no possible conversion, or this node is the source model. + continue; + } + + conversion[toModel] = wrapConversion(toModel, graph); + } + + return conversion; +}; + +var convert = {}; + +var models = Object.keys(conversions); + +function wrapRaw(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } + + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } + + return fn(args); + }; + + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } + + return wrappedFn; +} + +function wrapRounded(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } + + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } + + var result = fn(args); + + // we're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (var len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } + + return result; + }; + + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } + + return wrappedFn; +} + +models.forEach(function (fromModel) { + convert[fromModel] = {}; + + Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); + Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); + + var routes = route(fromModel); + var routeModels = Object.keys(routes); + + routeModels.forEach(function (toModel) { + var fn = routes[toModel]; + + convert[fromModel][toModel] = wrapRounded(fn); + convert[fromModel][toModel].raw = wrapRaw(fn); + }); +}); + +var colorConvert = convert; + +var colorName$1 = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; + +/* MIT license */ + + +var colorString = { + getRgba: getRgba, + getHsla: getHsla, + getRgb: getRgb, + getHsl: getHsl, + getHwb: getHwb, + getAlpha: getAlpha, + + hexString: hexString, + rgbString: rgbString, + rgbaString: rgbaString, + percentString: percentString, + percentaString: percentaString, + hslString: hslString, + hslaString: hslaString, + hwbString: hwbString, + keyword: keyword +}; + +function getRgba(string) { + if (!string) { + return; + } + var abbr = /^#([a-fA-F0-9]{3,4})$/i, + hex = /^#([a-fA-F0-9]{6}([a-fA-F0-9]{2})?)$/i, + rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i, + per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i, + keyword = /(\w+)/; + + var rgb = [0, 0, 0], + a = 1, + match = string.match(abbr), + hexAlpha = ""; + if (match) { + match = match[1]; + hexAlpha = match[3]; + for (var i = 0; i < rgb.length; i++) { + rgb[i] = parseInt(match[i] + match[i], 16); + } + if (hexAlpha) { + a = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100; + } + } + else if (match = string.match(hex)) { + hexAlpha = match[2]; + match = match[1]; + for (var i = 0; i < rgb.length; i++) { + rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16); + } + if (hexAlpha) { + a = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100; + } + } + else if (match = string.match(rgba)) { + for (var i = 0; i < rgb.length; i++) { + rgb[i] = parseInt(match[i + 1]); + } + a = parseFloat(match[4]); + } + else if (match = string.match(per)) { + for (var i = 0; i < rgb.length; i++) { + rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55); + } + a = parseFloat(match[4]); + } + else if (match = string.match(keyword)) { + if (match[1] == "transparent") { + return [0, 0, 0, 0]; + } + rgb = colorName$1[match[1]]; + if (!rgb) { + return; + } + } + + for (var i = 0; i < rgb.length; i++) { + rgb[i] = scale(rgb[i], 0, 255); + } + if (!a && a != 0) { + a = 1; + } + else { + a = scale(a, 0, 1); + } + rgb[3] = a; + return rgb; +} + +function getHsla(string) { + if (!string) { + return; + } + var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/; + var match = string.match(hsl); + if (match) { + var alpha = parseFloat(match[4]); + var h = scale(parseInt(match[1]), 0, 360), + s = scale(parseFloat(match[2]), 0, 100), + l = scale(parseFloat(match[3]), 0, 100), + a = scale(isNaN(alpha) ? 1 : alpha, 0, 1); + return [h, s, l, a]; + } +} + +function getHwb(string) { + if (!string) { + return; + } + var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/; + var match = string.match(hwb); + if (match) { + var alpha = parseFloat(match[4]); + var h = scale(parseInt(match[1]), 0, 360), + w = scale(parseFloat(match[2]), 0, 100), + b = scale(parseFloat(match[3]), 0, 100), + a = scale(isNaN(alpha) ? 1 : alpha, 0, 1); + return [h, w, b, a]; + } +} + +function getRgb(string) { + var rgba = getRgba(string); + return rgba && rgba.slice(0, 3); +} + +function getHsl(string) { + var hsla = getHsla(string); + return hsla && hsla.slice(0, 3); +} + +function getAlpha(string) { + var vals = getRgba(string); + if (vals) { + return vals[3]; + } + else if (vals = getHsla(string)) { + return vals[3]; + } + else if (vals = getHwb(string)) { + return vals[3]; + } +} + +// generators +function hexString(rgba, a) { + var a = (a !== undefined && rgba.length === 3) ? a : rgba[3]; + return "#" + hexDouble(rgba[0]) + + hexDouble(rgba[1]) + + hexDouble(rgba[2]) + + ( + (a >= 0 && a < 1) + ? hexDouble(Math.round(a * 255)) + : "" + ); +} + +function rgbString(rgba, alpha) { + if (alpha < 1 || (rgba[3] && rgba[3] < 1)) { + return rgbaString(rgba, alpha); + } + return "rgb(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + ")"; +} + +function rgbaString(rgba, alpha) { + if (alpha === undefined) { + alpha = (rgba[3] !== undefined ? rgba[3] : 1); + } + return "rgba(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + + ", " + alpha + ")"; +} + +function percentString(rgba, alpha) { + if (alpha < 1 || (rgba[3] && rgba[3] < 1)) { + return percentaString(rgba, alpha); + } + var r = Math.round(rgba[0]/255 * 100), + g = Math.round(rgba[1]/255 * 100), + b = Math.round(rgba[2]/255 * 100); + + return "rgb(" + r + "%, " + g + "%, " + b + "%)"; +} + +function percentaString(rgba, alpha) { + var r = Math.round(rgba[0]/255 * 100), + g = Math.round(rgba[1]/255 * 100), + b = Math.round(rgba[2]/255 * 100); + return "rgba(" + r + "%, " + g + "%, " + b + "%, " + (alpha || rgba[3] || 1) + ")"; +} + +function hslString(hsla, alpha) { + if (alpha < 1 || (hsla[3] && hsla[3] < 1)) { + return hslaString(hsla, alpha); + } + return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)"; +} + +function hslaString(hsla, alpha) { + if (alpha === undefined) { + alpha = (hsla[3] !== undefined ? hsla[3] : 1); + } + return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + + alpha + ")"; +} + +// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax +// (hwb have alpha optional & 1 is default value) +function hwbString(hwb, alpha) { + if (alpha === undefined) { + alpha = (hwb[3] !== undefined ? hwb[3] : 1); + } + return "hwb(" + hwb[0] + ", " + hwb[1] + "%, " + hwb[2] + "%" + + (alpha !== undefined && alpha !== 1 ? ", " + alpha : "") + ")"; +} + +function keyword(rgb) { + return reverseNames[rgb.slice(0, 3)]; +} + +// helpers +function scale(num, min, max) { + return Math.min(Math.max(min, num), max); +} + +function hexDouble(num) { + var str = num.toString(16).toUpperCase(); + return (str.length < 2) ? "0" + str : str; +} + + +//create a list of reverse color names +var reverseNames = {}; +for (var name in colorName$1) { + reverseNames[colorName$1[name]] = name; +} + +/* MIT license */ + + + +var Color = function (obj) { + if (obj instanceof Color) { + return obj; + } + if (!(this instanceof Color)) { + return new Color(obj); + } + + this.valid = false; + this.values = { + rgb: [0, 0, 0], + hsl: [0, 0, 0], + hsv: [0, 0, 0], + hwb: [0, 0, 0], + cmyk: [0, 0, 0, 0], + alpha: 1 + }; + + // parse Color() argument + var vals; + if (typeof obj === 'string') { + vals = colorString.getRgba(obj); + if (vals) { + this.setValues('rgb', vals); + } else if (vals = colorString.getHsla(obj)) { + this.setValues('hsl', vals); + } else if (vals = colorString.getHwb(obj)) { + this.setValues('hwb', vals); + } + } else if (typeof obj === 'object') { + vals = obj; + if (vals.r !== undefined || vals.red !== undefined) { + this.setValues('rgb', vals); + } else if (vals.l !== undefined || vals.lightness !== undefined) { + this.setValues('hsl', vals); + } else if (vals.v !== undefined || vals.value !== undefined) { + this.setValues('hsv', vals); + } else if (vals.w !== undefined || vals.whiteness !== undefined) { + this.setValues('hwb', vals); + } else if (vals.c !== undefined || vals.cyan !== undefined) { + this.setValues('cmyk', vals); + } + } +}; + +Color.prototype = { + isValid: function () { + return this.valid; + }, + rgb: function () { + return this.setSpace('rgb', arguments); + }, + hsl: function () { + return this.setSpace('hsl', arguments); + }, + hsv: function () { + return this.setSpace('hsv', arguments); + }, + hwb: function () { + return this.setSpace('hwb', arguments); + }, + cmyk: function () { + return this.setSpace('cmyk', arguments); + }, + + rgbArray: function () { + return this.values.rgb; + }, + hslArray: function () { + return this.values.hsl; + }, + hsvArray: function () { + return this.values.hsv; + }, + hwbArray: function () { + var values = this.values; + if (values.alpha !== 1) { + return values.hwb.concat([values.alpha]); + } + return values.hwb; + }, + cmykArray: function () { + return this.values.cmyk; + }, + rgbaArray: function () { + var values = this.values; + return values.rgb.concat([values.alpha]); + }, + hslaArray: function () { + var values = this.values; + return values.hsl.concat([values.alpha]); + }, + alpha: function (val) { + if (val === undefined) { + return this.values.alpha; + } + this.setValues('alpha', val); + return this; + }, + + red: function (val) { + return this.setChannel('rgb', 0, val); + }, + green: function (val) { + return this.setChannel('rgb', 1, val); + }, + blue: function (val) { + return this.setChannel('rgb', 2, val); + }, + hue: function (val) { + if (val) { + val %= 360; + val = val < 0 ? 360 + val : val; + } + return this.setChannel('hsl', 0, val); + }, + saturation: function (val) { + return this.setChannel('hsl', 1, val); + }, + lightness: function (val) { + return this.setChannel('hsl', 2, val); + }, + saturationv: function (val) { + return this.setChannel('hsv', 1, val); + }, + whiteness: function (val) { + return this.setChannel('hwb', 1, val); + }, + blackness: function (val) { + return this.setChannel('hwb', 2, val); + }, + value: function (val) { + return this.setChannel('hsv', 2, val); + }, + cyan: function (val) { + return this.setChannel('cmyk', 0, val); + }, + magenta: function (val) { + return this.setChannel('cmyk', 1, val); + }, + yellow: function (val) { + return this.setChannel('cmyk', 2, val); + }, + black: function (val) { + return this.setChannel('cmyk', 3, val); + }, + + hexString: function () { + return colorString.hexString(this.values.rgb); + }, + rgbString: function () { + return colorString.rgbString(this.values.rgb, this.values.alpha); + }, + rgbaString: function () { + return colorString.rgbaString(this.values.rgb, this.values.alpha); + }, + percentString: function () { + return colorString.percentString(this.values.rgb, this.values.alpha); + }, + hslString: function () { + return colorString.hslString(this.values.hsl, this.values.alpha); + }, + hslaString: function () { + return colorString.hslaString(this.values.hsl, this.values.alpha); + }, + hwbString: function () { + return colorString.hwbString(this.values.hwb, this.values.alpha); + }, + keyword: function () { + return colorString.keyword(this.values.rgb, this.values.alpha); + }, + + rgbNumber: function () { + var rgb = this.values.rgb; + return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2]; + }, + + luminosity: function () { + // http://www.w3.org/TR/WCAG20/#relativeluminancedef + var rgb = this.values.rgb; + var lum = []; + for (var i = 0; i < rgb.length; i++) { + var chan = rgb[i] / 255; + lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4); + } + return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2]; + }, + + contrast: function (color2) { + // http://www.w3.org/TR/WCAG20/#contrast-ratiodef + var lum1 = this.luminosity(); + var lum2 = color2.luminosity(); + if (lum1 > lum2) { + return (lum1 + 0.05) / (lum2 + 0.05); + } + return (lum2 + 0.05) / (lum1 + 0.05); + }, + + level: function (color2) { + var contrastRatio = this.contrast(color2); + if (contrastRatio >= 7.1) { + return 'AAA'; + } + + return (contrastRatio >= 4.5) ? 'AA' : ''; + }, + + dark: function () { + // YIQ equation from http://24ways.org/2010/calculating-color-contrast + var rgb = this.values.rgb; + var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000; + return yiq < 128; + }, + + light: function () { + return !this.dark(); + }, + + negate: function () { + var rgb = []; + for (var i = 0; i < 3; i++) { + rgb[i] = 255 - this.values.rgb[i]; + } + this.setValues('rgb', rgb); + return this; + }, + + lighten: function (ratio) { + var hsl = this.values.hsl; + hsl[2] += hsl[2] * ratio; + this.setValues('hsl', hsl); + return this; + }, + + darken: function (ratio) { + var hsl = this.values.hsl; + hsl[2] -= hsl[2] * ratio; + this.setValues('hsl', hsl); + return this; + }, + + saturate: function (ratio) { + var hsl = this.values.hsl; + hsl[1] += hsl[1] * ratio; + this.setValues('hsl', hsl); + return this; + }, + + desaturate: function (ratio) { + var hsl = this.values.hsl; + hsl[1] -= hsl[1] * ratio; + this.setValues('hsl', hsl); + return this; + }, + + whiten: function (ratio) { + var hwb = this.values.hwb; + hwb[1] += hwb[1] * ratio; + this.setValues('hwb', hwb); + return this; + }, + + blacken: function (ratio) { + var hwb = this.values.hwb; + hwb[2] += hwb[2] * ratio; + this.setValues('hwb', hwb); + return this; + }, + + greyscale: function () { + var rgb = this.values.rgb; + // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale + var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11; + this.setValues('rgb', [val, val, val]); + return this; + }, + + clearer: function (ratio) { + var alpha = this.values.alpha; + this.setValues('alpha', alpha - (alpha * ratio)); + return this; + }, + + opaquer: function (ratio) { + var alpha = this.values.alpha; + this.setValues('alpha', alpha + (alpha * ratio)); + return this; + }, + + rotate: function (degrees) { + var hsl = this.values.hsl; + var hue = (hsl[0] + degrees) % 360; + hsl[0] = hue < 0 ? 360 + hue : hue; + this.setValues('hsl', hsl); + return this; + }, + + /** + * Ported from sass implementation in C + * https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209 + */ + mix: function (mixinColor, weight) { + var color1 = this; + var color2 = mixinColor; + var p = weight === undefined ? 0.5 : weight; + + var w = 2 * p - 1; + var a = color1.alpha() - color2.alpha(); + + var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; + var w2 = 1 - w1; + + return this + .rgb( + w1 * color1.red() + w2 * color2.red(), + w1 * color1.green() + w2 * color2.green(), + w1 * color1.blue() + w2 * color2.blue() + ) + .alpha(color1.alpha() * p + color2.alpha() * (1 - p)); + }, + + toJSON: function () { + return this.rgb(); + }, + + clone: function () { + // NOTE(SB): using node-clone creates a dependency to Buffer when using browserify, + // making the final build way to big to embed in Chart.js. So let's do it manually, + // assuming that values to clone are 1 dimension arrays containing only numbers, + // except 'alpha' which is a number. + var result = new Color(); + var source = this.values; + var target = result.values; + var value, type; + + for (var prop in source) { + if (source.hasOwnProperty(prop)) { + value = source[prop]; + type = ({}).toString.call(value); + if (type === '[object Array]') { + target[prop] = value.slice(0); + } else if (type === '[object Number]') { + target[prop] = value; + } else { + console.error('unexpected color value:', value); + } + } + } + + return result; + } +}; + +Color.prototype.spaces = { + rgb: ['red', 'green', 'blue'], + hsl: ['hue', 'saturation', 'lightness'], + hsv: ['hue', 'saturation', 'value'], + hwb: ['hue', 'whiteness', 'blackness'], + cmyk: ['cyan', 'magenta', 'yellow', 'black'] +}; + +Color.prototype.maxes = { + rgb: [255, 255, 255], + hsl: [360, 100, 100], + hsv: [360, 100, 100], + hwb: [360, 100, 100], + cmyk: [100, 100, 100, 100] +}; + +Color.prototype.getValues = function (space) { + var values = this.values; + var vals = {}; + + for (var i = 0; i < space.length; i++) { + vals[space.charAt(i)] = values[space][i]; + } + + if (values.alpha !== 1) { + vals.a = values.alpha; + } + + // {r: 255, g: 255, b: 255, a: 0.4} + return vals; +}; + +Color.prototype.setValues = function (space, vals) { + var values = this.values; + var spaces = this.spaces; + var maxes = this.maxes; + var alpha = 1; + var i; + + this.valid = true; + + if (space === 'alpha') { + alpha = vals; + } else if (vals.length) { + // [10, 10, 10] + values[space] = vals.slice(0, space.length); + alpha = vals[space.length]; + } else if (vals[space.charAt(0)] !== undefined) { + // {r: 10, g: 10, b: 10} + for (i = 0; i < space.length; i++) { + values[space][i] = vals[space.charAt(i)]; + } + + alpha = vals.a; + } else if (vals[spaces[space][0]] !== undefined) { + // {red: 10, green: 10, blue: 10} + var chans = spaces[space]; + + for (i = 0; i < space.length; i++) { + values[space][i] = vals[chans[i]]; + } + + alpha = vals.alpha; + } + + values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? values.alpha : alpha))); + + if (space === 'alpha') { + return false; + } + + var capped; + + // cap values of the space prior converting all values + for (i = 0; i < space.length; i++) { + capped = Math.max(0, Math.min(maxes[space][i], values[space][i])); + values[space][i] = Math.round(capped); + } + + // convert to all the other color spaces + for (var sname in spaces) { + if (sname !== space) { + values[sname] = colorConvert[space][sname](values[space]); + } + } + + return true; +}; + +Color.prototype.setSpace = function (space, args) { + var vals = args[0]; + + if (vals === undefined) { + // color.rgb() + return this.getValues(space); + } + + // color.rgb(10, 10, 10) + if (typeof vals === 'number') { + vals = Array.prototype.slice.call(args); + } + + this.setValues(space, vals); + return this; +}; + +Color.prototype.setChannel = function (space, index, val) { + var svalues = this.values[space]; + if (val === undefined) { + // color.red() + return svalues[index]; + } else if (val === svalues[index]) { + // color.red(color.red()) + return this; + } + + // color.red(100) + svalues[index] = val; + this.setValues(space, svalues); + + return this; +}; + +if (typeof window !== 'undefined') { + window.Color = Color; +} + +var chartjsColor = Color; + +/** + * @namespace Chart.helpers + */ +var helpers = { + /** + * An empty function that can be used, for example, for optional callback. + */ + noop: function() {}, + + /** + * Returns a unique id, sequentially generated from a global variable. + * @returns {number} + * @function + */ + uid: (function() { + var id = 0; + return function() { + return id++; + }; + }()), + + /** + * Returns true if `value` is neither null nor undefined, else returns false. + * @param {*} value - The value to test. + * @returns {boolean} + * @since 2.7.0 + */ + isNullOrUndef: function(value) { + return value === null || typeof value === 'undefined'; + }, + + /** + * Returns true if `value` is an array (including typed arrays), else returns false. + * @param {*} value - The value to test. + * @returns {boolean} + * @function + */ + isArray: function(value) { + if (Array.isArray && Array.isArray(value)) { + return true; + } + var type = Object.prototype.toString.call(value); + if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') { + return true; + } + return false; + }, + + /** + * Returns true if `value` is an object (excluding null), else returns false. + * @param {*} value - The value to test. + * @returns {boolean} + * @since 2.7.0 + */ + isObject: function(value) { + return value !== null && Object.prototype.toString.call(value) === '[object Object]'; + }, + + /** + * Returns true if `value` is a finite number, else returns false + * @param {*} value - The value to test. + * @returns {boolean} + */ + isFinite: function(value) { + return (typeof value === 'number' || value instanceof Number) && isFinite(value); + }, + + /** + * Returns `value` if defined, else returns `defaultValue`. + * @param {*} value - The value to return if defined. + * @param {*} defaultValue - The value to return if `value` is undefined. + * @returns {*} + */ + valueOrDefault: function(value, defaultValue) { + return typeof value === 'undefined' ? defaultValue : value; + }, + + /** + * Returns value at the given `index` in array if defined, else returns `defaultValue`. + * @param {Array} value - The array to lookup for value at `index`. + * @param {number} index - The index in `value` to lookup for value. + * @param {*} defaultValue - The value to return if `value[index]` is undefined. + * @returns {*} + */ + valueAtIndexOrDefault: function(value, index, defaultValue) { + return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue); + }, + + /** + * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the + * value returned by `fn`. If `fn` is not a function, this method returns undefined. + * @param {function} fn - The function to call. + * @param {Array|undefined|null} args - The arguments with which `fn` should be called. + * @param {object} [thisArg] - The value of `this` provided for the call to `fn`. + * @returns {*} + */ + callback: function(fn, args, thisArg) { + if (fn && typeof fn.call === 'function') { + return fn.apply(thisArg, args); + } + }, + + /** + * Note(SB) for performance sake, this method should only be used when loopable type + * is unknown or in none intensive code (not called often and small loopable). Else + * it's preferable to use a regular for() loop and save extra function calls. + * @param {object|Array} loopable - The object or array to be iterated. + * @param {function} fn - The function to call for each item. + * @param {object} [thisArg] - The value of `this` provided for the call to `fn`. + * @param {boolean} [reverse] - If true, iterates backward on the loopable. + */ + each: function(loopable, fn, thisArg, reverse) { + var i, len, keys; + if (helpers.isArray(loopable)) { + len = loopable.length; + if (reverse) { + for (i = len - 1; i >= 0; i--) { + fn.call(thisArg, loopable[i], i); + } + } else { + for (i = 0; i < len; i++) { + fn.call(thisArg, loopable[i], i); + } + } + } else if (helpers.isObject(loopable)) { + keys = Object.keys(loopable); + len = keys.length; + for (i = 0; i < len; i++) { + fn.call(thisArg, loopable[keys[i]], keys[i]); + } + } + }, + + /** + * Returns true if the `a0` and `a1` arrays have the same content, else returns false. + * @see https://stackoverflow.com/a/14853974 + * @param {Array} a0 - The array to compare + * @param {Array} a1 - The array to compare + * @returns {boolean} + */ + arrayEquals: function(a0, a1) { + var i, ilen, v0, v1; + + if (!a0 || !a1 || a0.length !== a1.length) { + return false; + } + + for (i = 0, ilen = a0.length; i < ilen; ++i) { + v0 = a0[i]; + v1 = a1[i]; + + if (v0 instanceof Array && v1 instanceof Array) { + if (!helpers.arrayEquals(v0, v1)) { + return false; + } + } else if (v0 !== v1) { + // NOTE: two different object instances will never be equal: {x:20} != {x:20} + return false; + } + } + + return true; + }, + + /** + * Returns a deep copy of `source` without keeping references on objects and arrays. + * @param {*} source - The value to clone. + * @returns {*} + */ + clone: function(source) { + if (helpers.isArray(source)) { + return source.map(helpers.clone); + } + + if (helpers.isObject(source)) { + var target = {}; + var keys = Object.keys(source); + var klen = keys.length; + var k = 0; + + for (; k < klen; ++k) { + target[keys[k]] = helpers.clone(source[keys[k]]); + } + + return target; + } + + return source; + }, + + /** + * The default merger when Chart.helpers.merge is called without merger option. + * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback. + * @private + */ + _merger: function(key, target, source, options) { + var tval = target[key]; + var sval = source[key]; + + if (helpers.isObject(tval) && helpers.isObject(sval)) { + helpers.merge(tval, sval, options); + } else { + target[key] = helpers.clone(sval); + } + }, + + /** + * Merges source[key] in target[key] only if target[key] is undefined. + * @private + */ + _mergerIf: function(key, target, source) { + var tval = target[key]; + var sval = source[key]; + + if (helpers.isObject(tval) && helpers.isObject(sval)) { + helpers.mergeIf(tval, sval); + } else if (!target.hasOwnProperty(key)) { + target[key] = helpers.clone(sval); + } + }, + + /** + * Recursively deep copies `source` properties into `target` with the given `options`. + * IMPORTANT: `target` is not cloned and will be updated with `source` properties. + * @param {object} target - The target object in which all sources are merged into. + * @param {object|object[]} source - Object(s) to merge into `target`. + * @param {object} [options] - Merging options: + * @param {function} [options.merger] - The merge method (key, target, source, options) + * @returns {object} The `target` object. + */ + merge: function(target, source, options) { + var sources = helpers.isArray(source) ? source : [source]; + var ilen = sources.length; + var merge, i, keys, klen, k; + + if (!helpers.isObject(target)) { + return target; + } + + options = options || {}; + merge = options.merger || helpers._merger; + + for (i = 0; i < ilen; ++i) { + source = sources[i]; + if (!helpers.isObject(source)) { + continue; + } + + keys = Object.keys(source); + for (k = 0, klen = keys.length; k < klen; ++k) { + merge(keys[k], target, source, options); + } + } + + return target; + }, + + /** + * Recursively deep copies `source` properties into `target` *only* if not defined in target. + * IMPORTANT: `target` is not cloned and will be updated with `source` properties. + * @param {object} target - The target object in which all sources are merged into. + * @param {object|object[]} source - Object(s) to merge into `target`. + * @returns {object} The `target` object. + */ + mergeIf: function(target, source) { + return helpers.merge(target, source, {merger: helpers._mergerIf}); + }, + + /** + * Applies the contents of two or more objects together into the first object. + * @param {object} target - The target object in which all objects are merged into. + * @param {object} arg1 - Object containing additional properties to merge in target. + * @param {object} argN - Additional objects containing properties to merge in target. + * @returns {object} The `target` object. + */ + extend: Object.assign || function(target) { + return helpers.merge(target, [].slice.call(arguments, 1), { + merger: function(key, dst, src) { + dst[key] = src[key]; + } + }); + }, + + /** + * Basic javascript inheritance based on the model created in Backbone.js + */ + inherits: function(extensions) { + var me = this; + var ChartElement = (extensions && extensions.hasOwnProperty('constructor')) ? extensions.constructor : function() { + return me.apply(this, arguments); + }; + + var Surrogate = function() { + this.constructor = ChartElement; + }; + + Surrogate.prototype = me.prototype; + ChartElement.prototype = new Surrogate(); + ChartElement.extend = helpers.inherits; + + if (extensions) { + helpers.extend(ChartElement.prototype, extensions); + } + + ChartElement.__super__ = me.prototype; + return ChartElement; + }, + + _deprecated: function(scope, value, previous, current) { + if (value !== undefined) { + console.warn(scope + ': "' + previous + + '" is deprecated. Please use "' + current + '" instead'); + } + } +}; + +var helpers_core = helpers; + +// DEPRECATIONS + +/** + * Provided for backward compatibility, use Chart.helpers.callback instead. + * @function Chart.helpers.callCallback + * @deprecated since version 2.6.0 + * @todo remove at version 3 + * @private + */ +helpers.callCallback = helpers.callback; + +/** + * Provided for backward compatibility, use Array.prototype.indexOf instead. + * Array.prototype.indexOf compatibility: Chrome, Opera, Safari, FF1.5+, IE9+ + * @function Chart.helpers.indexOf + * @deprecated since version 2.7.0 + * @todo remove at version 3 + * @private + */ +helpers.indexOf = function(array, item, fromIndex) { + return Array.prototype.indexOf.call(array, item, fromIndex); +}; + +/** + * Provided for backward compatibility, use Chart.helpers.valueOrDefault instead. + * @function Chart.helpers.getValueOrDefault + * @deprecated since version 2.7.0 + * @todo remove at version 3 + * @private + */ +helpers.getValueOrDefault = helpers.valueOrDefault; + +/** + * Provided for backward compatibility, use Chart.helpers.valueAtIndexOrDefault instead. + * @function Chart.helpers.getValueAtIndexOrDefault + * @deprecated since version 2.7.0 + * @todo remove at version 3 + * @private + */ +helpers.getValueAtIndexOrDefault = helpers.valueAtIndexOrDefault; + +/** + * Easing functions adapted from Robert Penner's easing equations. + * @namespace Chart.helpers.easingEffects + * @see http://www.robertpenner.com/easing/ + */ +var effects = { + linear: function(t) { + return t; + }, + + easeInQuad: function(t) { + return t * t; + }, + + easeOutQuad: function(t) { + return -t * (t - 2); + }, + + easeInOutQuad: function(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t; + } + return -0.5 * ((--t) * (t - 2) - 1); + }, + + easeInCubic: function(t) { + return t * t * t; + }, + + easeOutCubic: function(t) { + return (t = t - 1) * t * t + 1; + }, + + easeInOutCubic: function(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t; + } + return 0.5 * ((t -= 2) * t * t + 2); + }, + + easeInQuart: function(t) { + return t * t * t * t; + }, + + easeOutQuart: function(t) { + return -((t = t - 1) * t * t * t - 1); + }, + + easeInOutQuart: function(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t * t; + } + return -0.5 * ((t -= 2) * t * t * t - 2); + }, + + easeInQuint: function(t) { + return t * t * t * t * t; + }, + + easeOutQuint: function(t) { + return (t = t - 1) * t * t * t * t + 1; + }, + + easeInOutQuint: function(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t * t * t; + } + return 0.5 * ((t -= 2) * t * t * t * t + 2); + }, + + easeInSine: function(t) { + return -Math.cos(t * (Math.PI / 2)) + 1; + }, + + easeOutSine: function(t) { + return Math.sin(t * (Math.PI / 2)); + }, + + easeInOutSine: function(t) { + return -0.5 * (Math.cos(Math.PI * t) - 1); + }, + + easeInExpo: function(t) { + return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1)); + }, + + easeOutExpo: function(t) { + return (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1; + }, + + easeInOutExpo: function(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 0.5) < 1) { + return 0.5 * Math.pow(2, 10 * (t - 1)); + } + return 0.5 * (-Math.pow(2, -10 * --t) + 2); + }, + + easeInCirc: function(t) { + if (t >= 1) { + return t; + } + return -(Math.sqrt(1 - t * t) - 1); + }, + + easeOutCirc: function(t) { + return Math.sqrt(1 - (t = t - 1) * t); + }, + + easeInOutCirc: function(t) { + if ((t /= 0.5) < 1) { + return -0.5 * (Math.sqrt(1 - t * t) - 1); + } + return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + + easeInElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if (!p) { + p = 0.3; + } + if (a < 1) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p)); + }, + + easeOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if (!p) { + p = 0.3; + } + if (a < 1) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1; + }, + + easeInOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 0.5) === 2) { + return 1; + } + if (!p) { + p = 0.45; + } + if (a < 1) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack: function(t) { + var s = 1.70158; + return t * t * ((s + 1) * t - s); + }, + + easeOutBack: function(t) { + var s = 1.70158; + return (t = t - 1) * t * ((s + 1) * t + s) + 1; + }, + + easeInOutBack: function(t) { + var s = 1.70158; + if ((t /= 0.5) < 1) { + return 0.5 * (t * t * (((s *= (1.525)) + 1) * t - s)); + } + return 0.5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); + }, + + easeInBounce: function(t) { + return 1 - effects.easeOutBounce(1 - t); + }, + + easeOutBounce: function(t) { + if (t < (1 / 2.75)) { + return 7.5625 * t * t; + } + if (t < (2 / 2.75)) { + return 7.5625 * (t -= (1.5 / 2.75)) * t + 0.75; + } + if (t < (2.5 / 2.75)) { + return 7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375; + } + return 7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375; + }, + + easeInOutBounce: function(t) { + if (t < 0.5) { + return effects.easeInBounce(t * 2) * 0.5; + } + return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5; + } +}; + +var helpers_easing = { + effects: effects +}; + +// DEPRECATIONS + +/** + * Provided for backward compatibility, use Chart.helpers.easing.effects instead. + * @function Chart.helpers.easingEffects + * @deprecated since version 2.7.0 + * @todo remove at version 3 + * @private + */ +helpers_core.easingEffects = effects; + +var PI = Math.PI; +var RAD_PER_DEG = PI / 180; +var DOUBLE_PI = PI * 2; +var HALF_PI = PI / 2; +var QUARTER_PI = PI / 4; +var TWO_THIRDS_PI = PI * 2 / 3; + +/** + * @namespace Chart.helpers.canvas + */ +var exports$1 = { + /** + * Clears the entire canvas associated to the given `chart`. + * @param {Chart} chart - The chart for which to clear the canvas. + */ + clear: function(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); + }, + + /** + * Creates a "path" for a rectangle with rounded corners at position (x, y) with a + * given size (width, height) and the same `radius` for all corners. + * @param {CanvasRenderingContext2D} ctx - The canvas 2D Context. + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangle's width. + * @param {number} height - The rectangle's height. + * @param {number} radius - The rounded amount (in pixels) for the four corners. + * @todo handle `radius` as top-left, top-right, bottom-right, bottom-left array/object? + */ + roundedRect: function(ctx, x, y, width, height, radius) { + if (radius) { + var r = Math.min(radius, height / 2, width / 2); + var left = x + r; + var top = y + r; + var right = x + width - r; + var bottom = y + height - r; + + ctx.moveTo(x, top); + if (left < right && top < bottom) { + ctx.arc(left, top, r, -PI, -HALF_PI); + ctx.arc(right, top, r, -HALF_PI, 0); + ctx.arc(right, bottom, r, 0, HALF_PI); + ctx.arc(left, bottom, r, HALF_PI, PI); + } else if (left < right) { + ctx.moveTo(left, y); + ctx.arc(right, top, r, -HALF_PI, HALF_PI); + ctx.arc(left, top, r, HALF_PI, PI + HALF_PI); + } else if (top < bottom) { + ctx.arc(left, top, r, -PI, 0); + ctx.arc(left, bottom, r, 0, PI); + } else { + ctx.arc(left, top, r, -PI, PI); + } + ctx.closePath(); + ctx.moveTo(x, y); + } else { + ctx.rect(x, y, width, height); + } + }, + + drawPoint: function(ctx, style, radius, x, y, rotation) { + var type, xOffset, yOffset, size, cornerRadius; + var rad = (rotation || 0) * RAD_PER_DEG; + + if (style && typeof style === 'object') { + type = style.toString(); + if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') { + ctx.save(); + ctx.translate(x, y); + ctx.rotate(rad); + ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height); + ctx.restore(); + return; + } + } + + if (isNaN(radius) || radius <= 0) { + return; + } + + ctx.beginPath(); + + switch (style) { + // Default includes circle + default: + ctx.arc(x, y, radius, 0, DOUBLE_PI); + ctx.closePath(); + break; + case 'triangle': + ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + rad += TWO_THIRDS_PI; + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + rad += TWO_THIRDS_PI; + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + ctx.closePath(); + break; + case 'rectRounded': + // NOTE: the rounded rect implementation changed to use `arc` instead of + // `quadraticCurveTo` since it generates better results when rect is + // almost a circle. 0.516 (instead of 0.5) produces results with visually + // closer proportion to the previous impl and it is inscribed in the + // circle with `radius`. For more details, see the following PRs: + // https://github.com/chartjs/Chart.js/issues/5597 + // https://github.com/chartjs/Chart.js/issues/5858 + cornerRadius = radius * 0.516; + size = radius - cornerRadius; + xOffset = Math.cos(rad + QUARTER_PI) * size; + yOffset = Math.sin(rad + QUARTER_PI) * size; + ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI); + ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad); + ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI); + ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI); + ctx.closePath(); + break; + case 'rect': + if (!rotation) { + size = Math.SQRT1_2 * radius; + ctx.rect(x - size, y - size, 2 * size, 2 * size); + break; + } + rad += QUARTER_PI; + /* falls through */ + case 'rectRot': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + yOffset, y - xOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.lineTo(x - yOffset, y + xOffset); + ctx.closePath(); + break; + case 'crossRot': + rad += QUARTER_PI; + /* falls through */ + case 'cross': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + break; + case 'star': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + rad += QUARTER_PI; + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + break; + case 'line': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + break; + case 'dash': + ctx.moveTo(x, y); + ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); + break; + } + + ctx.fill(); + ctx.stroke(); + }, + + /** + * Returns true if the point is inside the rectangle + * @param {object} point - The point to test + * @param {object} area - The rectangle + * @returns {boolean} + * @private + */ + _isPointInArea: function(point, area) { + var epsilon = 1e-6; // 1e-6 is margin in pixels for accumulated error. + + return point.x > area.left - epsilon && point.x < area.right + epsilon && + point.y > area.top - epsilon && point.y < area.bottom + epsilon; + }, + + clipArea: function(ctx, area) { + ctx.save(); + ctx.beginPath(); + ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top); + ctx.clip(); + }, + + unclipArea: function(ctx) { + ctx.restore(); + }, + + lineTo: function(ctx, previous, target, flip) { + var stepped = target.steppedLine; + if (stepped) { + if (stepped === 'middle') { + var midpoint = (previous.x + target.x) / 2.0; + ctx.lineTo(midpoint, flip ? target.y : previous.y); + ctx.lineTo(midpoint, flip ? previous.y : target.y); + } else if ((stepped === 'after' && !flip) || (stepped !== 'after' && flip)) { + ctx.lineTo(previous.x, target.y); + } else { + ctx.lineTo(target.x, previous.y); + } + ctx.lineTo(target.x, target.y); + return; + } + + if (!target.tension) { + ctx.lineTo(target.x, target.y); + return; + } + + ctx.bezierCurveTo( + flip ? previous.controlPointPreviousX : previous.controlPointNextX, + flip ? previous.controlPointPreviousY : previous.controlPointNextY, + flip ? target.controlPointNextX : target.controlPointPreviousX, + flip ? target.controlPointNextY : target.controlPointPreviousY, + target.x, + target.y); + } +}; + +var helpers_canvas = exports$1; + +// DEPRECATIONS + +/** + * Provided for backward compatibility, use Chart.helpers.canvas.clear instead. + * @namespace Chart.helpers.clear + * @deprecated since version 2.7.0 + * @todo remove at version 3 + * @private + */ +helpers_core.clear = exports$1.clear; + +/** + * Provided for backward compatibility, use Chart.helpers.canvas.roundedRect instead. + * @namespace Chart.helpers.drawRoundedRectangle + * @deprecated since version 2.7.0 + * @todo remove at version 3 + * @private + */ +helpers_core.drawRoundedRectangle = function(ctx) { + ctx.beginPath(); + exports$1.roundedRect.apply(exports$1, arguments); +}; + +var defaults = { + /** + * @private + */ + _set: function(scope, values) { + return helpers_core.merge(this[scope] || (this[scope] = {}), values); + } +}; + +// TODO(v3): remove 'global' from namespace. all default are global and +// there's inconsistency around which options are under 'global' +defaults._set('global', { + defaultColor: 'rgba(0,0,0,0.1)', + defaultFontColor: '#666', + defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + defaultFontSize: 12, + defaultFontStyle: 'normal', + defaultLineHeight: 1.2, + showLines: true +}); + +var core_defaults = defaults; + +var valueOrDefault = helpers_core.valueOrDefault; + +/** + * Converts the given font object into a CSS font string. + * @param {object} font - A font object. + * @return {string} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font + * @private + */ +function toFontString(font) { + if (!font || helpers_core.isNullOrUndef(font.size) || helpers_core.isNullOrUndef(font.family)) { + return null; + } + + return (font.style ? font.style + ' ' : '') + + (font.weight ? font.weight + ' ' : '') + + font.size + 'px ' + + font.family; +} + +/** + * @alias Chart.helpers.options + * @namespace + */ +var helpers_options = { + /** + * Converts the given line height `value` in pixels for a specific font `size`. + * @param {number|string} value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em'). + * @param {number} size - The font size (in pixels) used to resolve relative `value`. + * @returns {number} The effective line height in pixels (size * 1.2 if value is invalid). + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height + * @since 2.7.0 + */ + toLineHeight: function(value, size) { + var matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); + if (!matches || matches[1] === 'normal') { + return size * 1.2; + } + + value = +matches[2]; + + switch (matches[3]) { + case 'px': + return value; + case '%': + value /= 100; + break; + } + + return size * value; + }, + + /** + * Converts the given value into a padding object with pre-computed width/height. + * @param {number|object} value - If a number, set the value to all TRBL component, + * else, if and object, use defined properties and sets undefined ones to 0. + * @returns {object} The padding values (top, right, bottom, left, width, height) + * @since 2.7.0 + */ + toPadding: function(value) { + var t, r, b, l; + + if (helpers_core.isObject(value)) { + t = +value.top || 0; + r = +value.right || 0; + b = +value.bottom || 0; + l = +value.left || 0; + } else { + t = r = b = l = +value || 0; + } + + return { + top: t, + right: r, + bottom: b, + left: l, + height: t + b, + width: l + r + }; + }, + + /** + * Parses font options and returns the font object. + * @param {object} options - A object that contains font options to be parsed. + * @return {object} The font object. + * @todo Support font.* options and renamed to toFont(). + * @private + */ + _parseFont: function(options) { + var globalDefaults = core_defaults.global; + var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize); + var font = { + family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily), + lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.lineHeight, globalDefaults.defaultLineHeight), size), + size: size, + style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle), + weight: null, + string: '' + }; + + font.string = toFontString(font); + return font; + }, + + /** + * Evaluates the given `inputs` sequentially and returns the first defined value. + * @param {Array} inputs - An array of values, falling back to the last value. + * @param {object} [context] - If defined and the current value is a function, the value + * is called with `context` as first argument and the result becomes the new input. + * @param {number} [index] - If defined and the current value is an array, the value + * at `index` become the new input. + * @param {object} [info] - object to return information about resolution in + * @param {boolean} [info.cacheable] - Will be set to `false` if option is not cacheable. + * @since 2.7.0 + */ + resolve: function(inputs, context, index, info) { + var cacheable = true; + var i, ilen, value; + + for (i = 0, ilen = inputs.length; i < ilen; ++i) { + value = inputs[i]; + if (value === undefined) { + continue; + } + if (context !== undefined && typeof value === 'function') { + value = value(context); + cacheable = false; + } + if (index !== undefined && helpers_core.isArray(value)) { + value = value[index]; + cacheable = false; + } + if (value !== undefined) { + if (info && !cacheable) { + info.cacheable = false; + } + return value; + } + } + } +}; + +/** + * @alias Chart.helpers.math + * @namespace + */ +var exports$2 = { + /** + * Returns an array of factors sorted from 1 to sqrt(value) + * @private + */ + _factorize: function(value) { + var result = []; + var sqrt = Math.sqrt(value); + var i; + + for (i = 1; i < sqrt; i++) { + if (value % i === 0) { + result.push(i); + result.push(value / i); + } + } + if (sqrt === (sqrt | 0)) { // if value is a square number + result.push(sqrt); + } + + result.sort(function(a, b) { + return a - b; + }).pop(); + return result; + }, + + log10: Math.log10 || function(x) { + var exponent = Math.log(x) * Math.LOG10E; // Math.LOG10E = 1 / Math.LN10. + // Check for whole powers of 10, + // which due to floating point rounding error should be corrected. + var powerOf10 = Math.round(exponent); + var isPowerOf10 = x === Math.pow(10, powerOf10); + + return isPowerOf10 ? powerOf10 : exponent; + } +}; + +var helpers_math = exports$2; + +// DEPRECATIONS + +/** + * Provided for backward compatibility, use Chart.helpers.math.log10 instead. + * @namespace Chart.helpers.log10 + * @deprecated since version 2.9.0 + * @todo remove at version 3 + * @private + */ +helpers_core.log10 = exports$2.log10; + +var getRtlAdapter = function(rectX, width) { + return { + x: function(x) { + return rectX + rectX + width - x; + }, + setWidth: function(w) { + width = w; + }, + textAlign: function(align) { + if (align === 'center') { + return align; + } + return align === 'right' ? 'left' : 'right'; + }, + xPlus: function(x, value) { + return x - value; + }, + leftForLtr: function(x, itemWidth) { + return x - itemWidth; + }, + }; +}; + +var getLtrAdapter = function() { + return { + x: function(x) { + return x; + }, + setWidth: function(w) { // eslint-disable-line no-unused-vars + }, + textAlign: function(align) { + return align; + }, + xPlus: function(x, value) { + return x + value; + }, + leftForLtr: function(x, _itemWidth) { // eslint-disable-line no-unused-vars + return x; + }, + }; +}; + +var getAdapter = function(rtl, rectX, width) { + return rtl ? getRtlAdapter(rectX, width) : getLtrAdapter(); +}; + +var overrideTextDirection = function(ctx, direction) { + var style, original; + if (direction === 'ltr' || direction === 'rtl') { + style = ctx.canvas.style; + original = [ + style.getPropertyValue('direction'), + style.getPropertyPriority('direction'), + ]; + + style.setProperty('direction', direction, 'important'); + ctx.prevTextDirection = original; + } +}; + +var restoreTextDirection = function(ctx) { + var original = ctx.prevTextDirection; + if (original !== undefined) { + delete ctx.prevTextDirection; + ctx.canvas.style.setProperty('direction', original[0], original[1]); + } +}; + +var helpers_rtl = { + getRtlAdapter: getAdapter, + overrideTextDirection: overrideTextDirection, + restoreTextDirection: restoreTextDirection, +}; + +var helpers$1 = helpers_core; +var easing = helpers_easing; +var canvas = helpers_canvas; +var options = helpers_options; +var math = helpers_math; +var rtl = helpers_rtl; +helpers$1.easing = easing; +helpers$1.canvas = canvas; +helpers$1.options = options; +helpers$1.math = math; +helpers$1.rtl = rtl; + +function interpolate(start, view, model, ease) { + var keys = Object.keys(model); + var i, ilen, key, actual, origin, target, type, c0, c1; + + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + + target = model[key]; + + // if a value is added to the model after pivot() has been called, the view + // doesn't contain it, so let's initialize the view to the target value. + if (!view.hasOwnProperty(key)) { + view[key] = target; + } + + actual = view[key]; + + if (actual === target || key[0] === '_') { + continue; + } + + if (!start.hasOwnProperty(key)) { + start[key] = actual; + } + + origin = start[key]; + + type = typeof target; + + if (type === typeof origin) { + if (type === 'string') { + c0 = chartjsColor(origin); + if (c0.valid) { + c1 = chartjsColor(target); + if (c1.valid) { + view[key] = c1.mix(c0, ease).rgbString(); + continue; + } + } + } else if (helpers$1.isFinite(origin) && helpers$1.isFinite(target)) { + view[key] = origin + (target - origin) * ease; + continue; + } + } + + view[key] = target; + } +} + +var Element = function(configuration) { + helpers$1.extend(this, configuration); + this.initialize.apply(this, arguments); +}; + +helpers$1.extend(Element.prototype, { + _type: undefined, + + initialize: function() { + this.hidden = false; + }, + + pivot: function() { + var me = this; + if (!me._view) { + me._view = helpers$1.extend({}, me._model); + } + me._start = {}; + return me; + }, + + transition: function(ease) { + var me = this; + var model = me._model; + var start = me._start; + var view = me._view; + + // No animation -> No Transition + if (!model || ease === 1) { + me._view = helpers$1.extend({}, model); + me._start = null; + return me; + } + + if (!view) { + view = me._view = {}; + } + + if (!start) { + start = me._start = {}; + } + + interpolate(start, view, model, ease); + + return me; + }, + + tooltipPosition: function() { + return { + x: this._model.x, + y: this._model.y + }; + }, + + hasValue: function() { + return helpers$1.isNumber(this._model.x) && helpers$1.isNumber(this._model.y); + } +}); + +Element.extend = helpers$1.inherits; + +var core_element = Element; + +var exports$3 = core_element.extend({ + chart: null, // the animation associated chart instance + currentStep: 0, // the current animation step + numSteps: 60, // default number of steps + easing: '', // the easing to use for this animation + render: null, // render function used by the animation service + + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes +}); + +var core_animation = exports$3; + +// DEPRECATIONS + +/** + * Provided for backward compatibility, use Chart.Animation instead + * @prop Chart.Animation#animationObject + * @deprecated since version 2.6.0 + * @todo remove at version 3 + */ +Object.defineProperty(exports$3.prototype, 'animationObject', { + get: function() { + return this; + } +}); + +/** + * Provided for backward compatibility, use Chart.Animation#chart instead + * @prop Chart.Animation#chartInstance + * @deprecated since version 2.6.0 + * @todo remove at version 3 + */ +Object.defineProperty(exports$3.prototype, 'chartInstance', { + get: function() { + return this.chart; + }, + set: function(value) { + this.chart = value; + } +}); + +core_defaults._set('global', { + animation: { + duration: 1000, + easing: 'easeOutQuart', + onProgress: helpers$1.noop, + onComplete: helpers$1.noop + } +}); + +var core_animations = { + animations: [], + request: null, + + /** + * @param {Chart} chart - The chart to animate. + * @param {Chart.Animation} animation - The animation that we will animate. + * @param {number} duration - The animation duration in ms. + * @param {boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions + */ + addAnimation: function(chart, animation, duration, lazy) { + var animations = this.animations; + var i, ilen; + + animation.chart = chart; + animation.startTime = Date.now(); + animation.duration = duration; + + if (!lazy) { + chart.animating = true; + } + + for (i = 0, ilen = animations.length; i < ilen; ++i) { + if (animations[i].chart === chart) { + animations[i] = animation; + return; + } + } + + animations.push(animation); + + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (animations.length === 1) { + this.requestAnimationFrame(); + } + }, + + cancelAnimation: function(chart) { + var index = helpers$1.findIndex(this.animations, function(animation) { + return animation.chart === chart; + }); + + if (index !== -1) { + this.animations.splice(index, 1); + chart.animating = false; + } + }, + + requestAnimationFrame: function() { + var me = this; + if (me.request === null) { + // Skip animation frame requests until the active one is executed. + // This can happen when processing mouse events, e.g. 'mousemove' + // and 'mouseout' events will trigger multiple renders. + me.request = helpers$1.requestAnimFrame.call(window, function() { + me.request = null; + me.startDigest(); + }); + } + }, + + /** + * @private + */ + startDigest: function() { + var me = this; + + me.advance(); + + // Do we have more stuff to animate? + if (me.animations.length > 0) { + me.requestAnimationFrame(); + } + }, + + /** + * @private + */ + advance: function() { + var animations = this.animations; + var animation, chart, numSteps, nextStep; + var i = 0; + + // 1 animation per chart, so we are looping charts here + while (i < animations.length) { + animation = animations[i]; + chart = animation.chart; + numSteps = animation.numSteps; + + // Make sure that currentStep starts at 1 + // https://github.com/chartjs/Chart.js/issues/6104 + nextStep = Math.floor((Date.now() - animation.startTime) / animation.duration * numSteps) + 1; + animation.currentStep = Math.min(nextStep, numSteps); + + helpers$1.callback(animation.render, [chart, animation], chart); + helpers$1.callback(animation.onAnimationProgress, [animation], chart); + + if (animation.currentStep >= numSteps) { + helpers$1.callback(animation.onAnimationComplete, [animation], chart); + chart.animating = false; + animations.splice(i, 1); + } else { + ++i; + } + } + } +}; + +var resolve = helpers$1.options.resolve; + +var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift']; + +/** + * Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice', + * 'unshift') and notify the listener AFTER the array has been altered. Listeners are + * called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arguments. + */ +function listenArrayEvents(array, listener) { + if (array._chartjs) { + array._chartjs.listeners.push(listener); + return; + } + + Object.defineProperty(array, '_chartjs', { + configurable: true, + enumerable: false, + value: { + listeners: [listener] + } + }); + + arrayEvents.forEach(function(key) { + var method = 'onData' + key.charAt(0).toUpperCase() + key.slice(1); + var base = array[key]; + + Object.defineProperty(array, key, { + configurable: true, + enumerable: false, + value: function() { + var args = Array.prototype.slice.call(arguments); + var res = base.apply(this, args); + + helpers$1.each(array._chartjs.listeners, function(object) { + if (typeof object[method] === 'function') { + object[method].apply(object, args); + } + }); + + return res; + } + }); + }); +} + +/** + * Removes the given array event listener and cleanup extra attached properties (such as + * the _chartjs stub and overridden methods) if array doesn't have any more listeners. + */ +function unlistenArrayEvents(array, listener) { + var stub = array._chartjs; + if (!stub) { + return; + } + + var listeners = stub.listeners; + var index = listeners.indexOf(listener); + if (index !== -1) { + listeners.splice(index, 1); + } + + if (listeners.length > 0) { + return; + } + + arrayEvents.forEach(function(key) { + delete array[key]; + }); + + delete array._chartjs; +} + +// Base class for all dataset controllers (line, bar, etc) +var DatasetController = function(chart, datasetIndex) { + this.initialize(chart, datasetIndex); +}; + +helpers$1.extend(DatasetController.prototype, { + + /** + * Element type used to generate a meta dataset (e.g. Chart.element.Line). + * @type {Chart.core.element} + */ + datasetElementType: null, + + /** + * Element type used to generate a meta data (e.g. Chart.element.Point). + * @type {Chart.core.element} + */ + dataElementType: null, + + /** + * Dataset element option keys to be resolved in _resolveDatasetElementOptions. + * A derived controller may override this to resolve controller-specific options. + * The keys defined here are for backward compatibility for legend styles. + * @private + */ + _datasetElementOptions: [ + 'backgroundColor', + 'borderCapStyle', + 'borderColor', + 'borderDash', + 'borderDashOffset', + 'borderJoinStyle', + 'borderWidth' + ], + + /** + * Data element option keys to be resolved in _resolveDataElementOptions. + * A derived controller may override this to resolve controller-specific options. + * The keys defined here are for backward compatibility for legend styles. + * @private + */ + _dataElementOptions: [ + 'backgroundColor', + 'borderColor', + 'borderWidth', + 'pointStyle' + ], + + initialize: function(chart, datasetIndex) { + var me = this; + me.chart = chart; + me.index = datasetIndex; + me.linkScales(); + me.addElements(); + me._type = me.getMeta().type; + }, + + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, + + linkScales: function() { + var me = this; + var meta = me.getMeta(); + var chart = me.chart; + var scales = chart.scales; + var dataset = me.getDataset(); + var scalesOpts = chart.options.scales; + + if (meta.xAxisID === null || !(meta.xAxisID in scales) || dataset.xAxisID) { + meta.xAxisID = dataset.xAxisID || scalesOpts.xAxes[0].id; + } + if (meta.yAxisID === null || !(meta.yAxisID in scales) || dataset.yAxisID) { + meta.yAxisID = dataset.yAxisID || scalesOpts.yAxes[0].id; + } + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getMeta: function() { + return this.chart.getDatasetMeta(this.index); + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + /** + * @private + */ + _getValueScaleId: function() { + return this.getMeta().yAxisID; + }, + + /** + * @private + */ + _getIndexScaleId: function() { + return this.getMeta().xAxisID; + }, + + /** + * @private + */ + _getValueScale: function() { + return this.getScaleForId(this._getValueScaleId()); + }, + + /** + * @private + */ + _getIndexScale: function() { + return this.getScaleForId(this._getIndexScaleId()); + }, + + reset: function() { + this._update(true); + }, + + /** + * @private + */ + destroy: function() { + if (this._data) { + unlistenArrayEvents(this._data, this); + } + }, + + createMetaDataset: function() { + var me = this; + var type = me.datasetElementType; + return type && new type({ + _chart: me.chart, + _datasetIndex: me.index + }); + }, + + createMetaData: function(index) { + var me = this; + var type = me.dataElementType; + return type && new type({ + _chart: me.chart, + _datasetIndex: me.index, + _index: index + }); + }, + + addElements: function() { + var me = this; + var meta = me.getMeta(); + var data = me.getDataset().data || []; + var metaData = meta.data; + var i, ilen; + + for (i = 0, ilen = data.length; i < ilen; ++i) { + metaData[i] = metaData[i] || me.createMetaData(i); + } + + meta.dataset = meta.dataset || me.createMetaDataset(); + }, + + addElementAndReset: function(index) { + var element = this.createMetaData(index); + this.getMeta().data.splice(index, 0, element); + this.updateElement(element, index, true); + }, + + buildOrUpdateElements: function() { + var me = this; + var dataset = me.getDataset(); + var data = dataset.data || (dataset.data = []); + + // In order to correctly handle data addition/deletion animation (an thus simulate + // real-time charts), we need to monitor these data modifications and synchronize + // the internal meta data accordingly. + if (me._data !== data) { + if (me._data) { + // This case happens when the user replaced the data array instance. + unlistenArrayEvents(me._data, me); + } + + if (data && Object.isExtensible(data)) { + listenArrayEvents(data, me); + } + me._data = data; + } + + // Re-sync meta data in case the user replaced the data array or if we missed + // any updates and so make sure that we handle number of datapoints changing. + me.resyncElements(); + }, + + /** + * Returns the merged user-supplied and default dataset-level options + * @private + */ + _configure: function() { + var me = this; + me._config = helpers$1.merge({}, [ + me.chart.options.datasets[me._type], + me.getDataset(), + ], { + merger: function(key, target, source) { + if (key !== '_meta' && key !== 'data') { + helpers$1._merger(key, target, source); + } + } + }); + }, + + _update: function(reset) { + var me = this; + me._configure(); + me._cachedDataOpts = null; + me.update(reset); + }, + + update: helpers$1.noop, + + transition: function(easingValue) { + var meta = this.getMeta(); + var elements = meta.data || []; + var ilen = elements.length; + var i = 0; + + for (; i < ilen; ++i) { + elements[i].transition(easingValue); + } + + if (meta.dataset) { + meta.dataset.transition(easingValue); + } + }, + + draw: function() { + var meta = this.getMeta(); + var elements = meta.data || []; + var ilen = elements.length; + var i = 0; + + if (meta.dataset) { + meta.dataset.draw(); + } + + for (; i < ilen; ++i) { + elements[i].draw(); + } + }, + + /** + * Returns a set of predefined style properties that should be used to represent the dataset + * or the data if the index is specified + * @param {number} index - data index + * @return {IStyleInterface} style object + */ + getStyle: function(index) { + var me = this; + var meta = me.getMeta(); + var dataset = meta.dataset; + var style; + + me._configure(); + if (dataset && index === undefined) { + style = me._resolveDatasetElementOptions(dataset || {}); + } else { + index = index || 0; + style = me._resolveDataElementOptions(meta.data[index] || {}, index); + } + + if (style.fill === false || style.fill === null) { + style.backgroundColor = style.borderColor; + } + + return style; + }, + + /** + * @private + */ + _resolveDatasetElementOptions: function(element, hover) { + var me = this; + var chart = me.chart; + var datasetOpts = me._config; + var custom = element.custom || {}; + var options = chart.options.elements[me.datasetElementType.prototype._type] || {}; + var elementOptions = me._datasetElementOptions; + var values = {}; + var i, ilen, key, readKey; + + // Scriptable options + var context = { + chart: chart, + dataset: me.getDataset(), + datasetIndex: me.index, + hover: hover + }; + + for (i = 0, ilen = elementOptions.length; i < ilen; ++i) { + key = elementOptions[i]; + readKey = hover ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + values[key] = resolve([ + custom[readKey], + datasetOpts[readKey], + options[readKey] + ], context); + } + + return values; + }, + + /** + * @private + */ + _resolveDataElementOptions: function(element, index) { + var me = this; + var custom = element && element.custom; + var cached = me._cachedDataOpts; + if (cached && !custom) { + return cached; + } + var chart = me.chart; + var datasetOpts = me._config; + var options = chart.options.elements[me.dataElementType.prototype._type] || {}; + var elementOptions = me._dataElementOptions; + var values = {}; + + // Scriptable options + var context = { + chart: chart, + dataIndex: index, + dataset: me.getDataset(), + datasetIndex: me.index + }; + + // `resolve` sets cacheable to `false` if any option is indexed or scripted + var info = {cacheable: !custom}; + + var keys, i, ilen, key; + + custom = custom || {}; + + if (helpers$1.isArray(elementOptions)) { + for (i = 0, ilen = elementOptions.length; i < ilen; ++i) { + key = elementOptions[i]; + values[key] = resolve([ + custom[key], + datasetOpts[key], + options[key] + ], context, index, info); + } + } else { + keys = Object.keys(elementOptions); + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + values[key] = resolve([ + custom[key], + datasetOpts[elementOptions[key]], + datasetOpts[key], + options[key] + ], context, index, info); + } + } + + if (info.cacheable) { + me._cachedDataOpts = Object.freeze(values); + } + + return values; + }, + + removeHoverStyle: function(element) { + helpers$1.merge(element._model, element.$previousStyle || {}); + delete element.$previousStyle; + }, + + setHoverStyle: function(element) { + var dataset = this.chart.data.datasets[element._datasetIndex]; + var index = element._index; + var custom = element.custom || {}; + var model = element._model; + var getHoverColor = helpers$1.getHoverColor; + + element.$previousStyle = { + backgroundColor: model.backgroundColor, + borderColor: model.borderColor, + borderWidth: model.borderWidth + }; + + model.backgroundColor = resolve([custom.hoverBackgroundColor, dataset.hoverBackgroundColor, getHoverColor(model.backgroundColor)], undefined, index); + model.borderColor = resolve([custom.hoverBorderColor, dataset.hoverBorderColor, getHoverColor(model.borderColor)], undefined, index); + model.borderWidth = resolve([custom.hoverBorderWidth, dataset.hoverBorderWidth, model.borderWidth], undefined, index); + }, + + /** + * @private + */ + _removeDatasetHoverStyle: function() { + var element = this.getMeta().dataset; + + if (element) { + this.removeHoverStyle(element); + } + }, + + /** + * @private + */ + _setDatasetHoverStyle: function() { + var element = this.getMeta().dataset; + var prev = {}; + var i, ilen, key, keys, hoverOptions, model; + + if (!element) { + return; + } + + model = element._model; + hoverOptions = this._resolveDatasetElementOptions(element, true); + + keys = Object.keys(hoverOptions); + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + prev[key] = model[key]; + model[key] = hoverOptions[key]; + } + + element.$previousStyle = prev; + }, + + /** + * @private + */ + resyncElements: function() { + var me = this; + var meta = me.getMeta(); + var data = me.getDataset().data; + var numMeta = meta.data.length; + var numData = data.length; + + if (numData < numMeta) { + meta.data.splice(numData, numMeta - numData); + } else if (numData > numMeta) { + me.insertElements(numMeta, numData - numMeta); + } + }, + + /** + * @private + */ + insertElements: function(start, count) { + for (var i = 0; i < count; ++i) { + this.addElementAndReset(start + i); + } + }, + + /** + * @private + */ + onDataPush: function() { + var count = arguments.length; + this.insertElements(this.getDataset().data.length - count, count); + }, + + /** + * @private + */ + onDataPop: function() { + this.getMeta().data.pop(); + }, + + /** + * @private + */ + onDataShift: function() { + this.getMeta().data.shift(); + }, + + /** + * @private + */ + onDataSplice: function(start, count) { + this.getMeta().data.splice(start, count); + this.insertElements(start, arguments.length - 2); + }, + + /** + * @private + */ + onDataUnshift: function() { + this.insertElements(0, arguments.length); + } +}); + +DatasetController.extend = helpers$1.inherits; + +var core_datasetController = DatasetController; + +var TAU = Math.PI * 2; + +core_defaults._set('global', { + elements: { + arc: { + backgroundColor: core_defaults.global.defaultColor, + borderColor: '#fff', + borderWidth: 2, + borderAlign: 'center' + } + } +}); + +function clipArc(ctx, arc) { + var startAngle = arc.startAngle; + var endAngle = arc.endAngle; + var pixelMargin = arc.pixelMargin; + var angleMargin = pixelMargin / arc.outerRadius; + var x = arc.x; + var y = arc.y; + + // Draw an inner border by cliping the arc and drawing a double-width border + // Enlarge the clipping arc by 0.33 pixels to eliminate glitches between borders + ctx.beginPath(); + ctx.arc(x, y, arc.outerRadius, startAngle - angleMargin, endAngle + angleMargin); + if (arc.innerRadius > pixelMargin) { + angleMargin = pixelMargin / arc.innerRadius; + ctx.arc(x, y, arc.innerRadius - pixelMargin, endAngle + angleMargin, startAngle - angleMargin, true); + } else { + ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI / 2); + } + ctx.closePath(); + ctx.clip(); +} + +function drawFullCircleBorders(ctx, vm, arc, inner) { + var endAngle = arc.endAngle; + var i; + + if (inner) { + arc.endAngle = arc.startAngle + TAU; + clipArc(ctx, arc); + arc.endAngle = endAngle; + if (arc.endAngle === arc.startAngle && arc.fullCircles) { + arc.endAngle += TAU; + arc.fullCircles--; + } + } + + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.startAngle + TAU, arc.startAngle, true); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.stroke(); + } + + ctx.beginPath(); + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.startAngle + TAU); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.stroke(); + } +} + +function drawBorder(ctx, vm, arc) { + var inner = vm.borderAlign === 'inner'; + + if (inner) { + ctx.lineWidth = vm.borderWidth * 2; + ctx.lineJoin = 'round'; + } else { + ctx.lineWidth = vm.borderWidth; + ctx.lineJoin = 'bevel'; + } + + if (arc.fullCircles) { + drawFullCircleBorders(ctx, vm, arc, inner); + } + + if (inner) { + clipArc(ctx, arc); + } + + ctx.beginPath(); + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + ctx.stroke(); +} + +var element_arc = core_element.extend({ + _type: 'arc', + + inLabelRange: function(mouseX) { + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } + return false; + }, + + inRange: function(chartX, chartY) { + var vm = this._view; + + if (vm) { + var pointRelativePosition = helpers$1.getAngleFromPoint(vm, {x: chartX, y: chartY}); + var angle = pointRelativePosition.angle; + var distance = pointRelativePosition.distance; + + // Sanitise angle range + var startAngle = vm.startAngle; + var endAngle = vm.endAngle; + while (endAngle < startAngle) { + endAngle += TAU; + } + while (angle > endAngle) { + angle -= TAU; + } + while (angle < startAngle) { + angle += TAU; + } + + // Check if within the range of the open/close angle + var betweenAngles = (angle >= startAngle && angle <= endAngle); + var withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius); + + return (betweenAngles && withinRadius); + } + return false; + }, + + getCenterPoint: function() { + var vm = this._view; + var halfAngle = (vm.startAngle + vm.endAngle) / 2; + var halfRadius = (vm.innerRadius + vm.outerRadius) / 2; + return { + x: vm.x + Math.cos(halfAngle) * halfRadius, + y: vm.y + Math.sin(halfAngle) * halfRadius + }; + }, + + getArea: function() { + var vm = this._view; + return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math.pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2)); + }, + + tooltipPosition: function() { + var vm = this._view; + var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2); + var rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; + + return { + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) + }; + }, + + draw: function() { + var ctx = this._chart.ctx; + var vm = this._view; + var pixelMargin = (vm.borderAlign === 'inner') ? 0.33 : 0; + var arc = { + x: vm.x, + y: vm.y, + innerRadius: vm.innerRadius, + outerRadius: Math.max(vm.outerRadius - pixelMargin, 0), + pixelMargin: pixelMargin, + startAngle: vm.startAngle, + endAngle: vm.endAngle, + fullCircles: Math.floor(vm.circumference / TAU) + }; + var i; + + ctx.save(); + + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + + if (arc.fullCircles) { + arc.endAngle = arc.startAngle + TAU; + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.fill(); + } + arc.endAngle = arc.startAngle + vm.circumference % TAU; + } + + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + ctx.fill(); + + if (vm.borderWidth) { + drawBorder(ctx, vm, arc); + } + + ctx.restore(); + } +}); + +var valueOrDefault$1 = helpers$1.valueOrDefault; + +var defaultColor = core_defaults.global.defaultColor; + +core_defaults._set('global', { + elements: { + line: { + tension: 0.4, + backgroundColor: defaultColor, + borderWidth: 3, + borderColor: defaultColor, + borderCapStyle: 'butt', + borderDash: [], + borderDashOffset: 0.0, + borderJoinStyle: 'miter', + capBezierPoints: true, + fill: true, // do we fill in the area between the line and its base axis + } + } +}); + +var element_line = core_element.extend({ + _type: 'line', + + draw: function() { + var me = this; + var vm = me._view; + var ctx = me._chart.ctx; + var spanGaps = vm.spanGaps; + var points = me._children.slice(); // clone array + var globalDefaults = core_defaults.global; + var globalOptionLineElements = globalDefaults.elements.line; + var lastDrawnIndex = -1; + var closePath = me._loop; + var index, previous, currentVM; + + if (!points.length) { + return; + } + + if (me._loop) { + for (index = 0; index < points.length; ++index) { + previous = helpers$1.previousItem(points, index); + // If the line has an open path, shift the point array + if (!points[index]._view.skip && previous._view.skip) { + points = points.slice(index).concat(points.slice(0, index)); + closePath = spanGaps; + break; + } + } + // If the line has a close path, add the first point again + if (closePath) { + points.push(points[0]); + } + } + + ctx.save(); + + // Stroke Line Options + ctx.lineCap = vm.borderCapStyle || globalOptionLineElements.borderCapStyle; + + // IE 9 and 10 do not support line dash + if (ctx.setLineDash) { + ctx.setLineDash(vm.borderDash || globalOptionLineElements.borderDash); + } + + ctx.lineDashOffset = valueOrDefault$1(vm.borderDashOffset, globalOptionLineElements.borderDashOffset); + ctx.lineJoin = vm.borderJoinStyle || globalOptionLineElements.borderJoinStyle; + ctx.lineWidth = valueOrDefault$1(vm.borderWidth, globalOptionLineElements.borderWidth); + ctx.strokeStyle = vm.borderColor || globalDefaults.defaultColor; + + // Stroke Line + ctx.beginPath(); + + // First point moves to it's starting position no matter what + currentVM = points[0]._view; + if (!currentVM.skip) { + ctx.moveTo(currentVM.x, currentVM.y); + lastDrawnIndex = 0; + } + + for (index = 1; index < points.length; ++index) { + currentVM = points[index]._view; + previous = lastDrawnIndex === -1 ? helpers$1.previousItem(points, index) : points[lastDrawnIndex]; + + if (!currentVM.skip) { + if ((lastDrawnIndex !== (index - 1) && !spanGaps) || lastDrawnIndex === -1) { + // There was a gap and this is the first point after the gap + ctx.moveTo(currentVM.x, currentVM.y); + } else { + // Line to next point + helpers$1.canvas.lineTo(ctx, previous._view, currentVM); + } + lastDrawnIndex = index; + } + } + + if (closePath) { + ctx.closePath(); + } + + ctx.stroke(); + ctx.restore(); + } +}); + +var valueOrDefault$2 = helpers$1.valueOrDefault; + +var defaultColor$1 = core_defaults.global.defaultColor; + +core_defaults._set('global', { + elements: { + point: { + radius: 3, + pointStyle: 'circle', + backgroundColor: defaultColor$1, + borderColor: defaultColor$1, + borderWidth: 1, + // Hover + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1 + } + } +}); + +function xRange(mouseX) { + var vm = this._view; + return vm ? (Math.abs(mouseX - vm.x) < vm.radius + vm.hitRadius) : false; +} + +function yRange(mouseY) { + var vm = this._view; + return vm ? (Math.abs(mouseY - vm.y) < vm.radius + vm.hitRadius) : false; +} + +var element_point = core_element.extend({ + _type: 'point', + + inRange: function(mouseX, mouseY) { + var vm = this._view; + return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(vm.hitRadius + vm.radius, 2)) : false; + }, + + inLabelRange: xRange, + inXRange: xRange, + inYRange: yRange, + + getCenterPoint: function() { + var vm = this._view; + return { + x: vm.x, + y: vm.y + }; + }, + + getArea: function() { + return Math.PI * Math.pow(this._view.radius, 2); + }, + + tooltipPosition: function() { + var vm = this._view; + return { + x: vm.x, + y: vm.y, + padding: vm.radius + vm.borderWidth + }; + }, + + draw: function(chartArea) { + var vm = this._view; + var ctx = this._chart.ctx; + var pointStyle = vm.pointStyle; + var rotation = vm.rotation; + var radius = vm.radius; + var x = vm.x; + var y = vm.y; + var globalDefaults = core_defaults.global; + var defaultColor = globalDefaults.defaultColor; // eslint-disable-line no-shadow + + if (vm.skip) { + return; + } + + // Clipping for Points. + if (chartArea === undefined || helpers$1.canvas._isPointInArea(vm, chartArea)) { + ctx.strokeStyle = vm.borderColor || defaultColor; + ctx.lineWidth = valueOrDefault$2(vm.borderWidth, globalDefaults.elements.point.borderWidth); + ctx.fillStyle = vm.backgroundColor || defaultColor; + helpers$1.canvas.drawPoint(ctx, pointStyle, radius, x, y, rotation); + } + } +}); + +var defaultColor$2 = core_defaults.global.defaultColor; + +core_defaults._set('global', { + elements: { + rectangle: { + backgroundColor: defaultColor$2, + borderColor: defaultColor$2, + borderSkipped: 'bottom', + borderWidth: 0 + } + } +}); + +function isVertical(vm) { + return vm && vm.width !== undefined; +} + +/** + * Helper function to get the bounds of the bar regardless of the orientation + * @param bar {Chart.Element.Rectangle} the bar + * @return {Bounds} bounds of the bar + * @private + */ +function getBarBounds(vm) { + var x1, x2, y1, y2, half; + + if (isVertical(vm)) { + half = vm.width / 2; + x1 = vm.x - half; + x2 = vm.x + half; + y1 = Math.min(vm.y, vm.base); + y2 = Math.max(vm.y, vm.base); + } else { + half = vm.height / 2; + x1 = Math.min(vm.x, vm.base); + x2 = Math.max(vm.x, vm.base); + y1 = vm.y - half; + y2 = vm.y + half; + } + + return { + left: x1, + top: y1, + right: x2, + bottom: y2 + }; +} + +function swap(orig, v1, v2) { + return orig === v1 ? v2 : orig === v2 ? v1 : orig; +} + +function parseBorderSkipped(vm) { + var edge = vm.borderSkipped; + var res = {}; + + if (!edge) { + return res; + } + + if (vm.horizontal) { + if (vm.base > vm.x) { + edge = swap(edge, 'left', 'right'); + } + } else if (vm.base < vm.y) { + edge = swap(edge, 'bottom', 'top'); + } + + res[edge] = true; + return res; +} + +function parseBorderWidth(vm, maxW, maxH) { + var value = vm.borderWidth; + var skip = parseBorderSkipped(vm); + var t, r, b, l; + + if (helpers$1.isObject(value)) { + t = +value.top || 0; + r = +value.right || 0; + b = +value.bottom || 0; + l = +value.left || 0; + } else { + t = r = b = l = +value || 0; + } + + return { + t: skip.top || (t < 0) ? 0 : t > maxH ? maxH : t, + r: skip.right || (r < 0) ? 0 : r > maxW ? maxW : r, + b: skip.bottom || (b < 0) ? 0 : b > maxH ? maxH : b, + l: skip.left || (l < 0) ? 0 : l > maxW ? maxW : l + }; +} + +function boundingRects(vm) { + var bounds = getBarBounds(vm); + var width = bounds.right - bounds.left; + var height = bounds.bottom - bounds.top; + var border = parseBorderWidth(vm, width / 2, height / 2); + + return { + outer: { + x: bounds.left, + y: bounds.top, + w: width, + h: height + }, + inner: { + x: bounds.left + border.l, + y: bounds.top + border.t, + w: width - border.l - border.r, + h: height - border.t - border.b + } + }; +} + +function inRange(vm, x, y) { + var skipX = x === null; + var skipY = y === null; + var bounds = !vm || (skipX && skipY) ? false : getBarBounds(vm); + + return bounds + && (skipX || x >= bounds.left && x <= bounds.right) + && (skipY || y >= bounds.top && y <= bounds.bottom); +} + +var element_rectangle = core_element.extend({ + _type: 'rectangle', + + draw: function() { + var ctx = this._chart.ctx; + var vm = this._view; + var rects = boundingRects(vm); + var outer = rects.outer; + var inner = rects.inner; + + ctx.fillStyle = vm.backgroundColor; + ctx.fillRect(outer.x, outer.y, outer.w, outer.h); + + if (outer.w === inner.w && outer.h === inner.h) { + return; + } + + ctx.save(); + ctx.beginPath(); + ctx.rect(outer.x, outer.y, outer.w, outer.h); + ctx.clip(); + ctx.fillStyle = vm.borderColor; + ctx.rect(inner.x, inner.y, inner.w, inner.h); + ctx.fill('evenodd'); + ctx.restore(); + }, + + height: function() { + var vm = this._view; + return vm.base - vm.y; + }, + + inRange: function(mouseX, mouseY) { + return inRange(this._view, mouseX, mouseY); + }, + + inLabelRange: function(mouseX, mouseY) { + var vm = this._view; + return isVertical(vm) + ? inRange(vm, mouseX, null) + : inRange(vm, null, mouseY); + }, + + inXRange: function(mouseX) { + return inRange(this._view, mouseX, null); + }, + + inYRange: function(mouseY) { + return inRange(this._view, null, mouseY); + }, + + getCenterPoint: function() { + var vm = this._view; + var x, y; + if (isVertical(vm)) { + x = vm.x; + y = (vm.y + vm.base) / 2; + } else { + x = (vm.x + vm.base) / 2; + y = vm.y; + } + + return {x: x, y: y}; + }, + + getArea: function() { + var vm = this._view; + + return isVertical(vm) + ? vm.width * Math.abs(vm.y - vm.base) + : vm.height * Math.abs(vm.x - vm.base); + }, + + tooltipPosition: function() { + var vm = this._view; + return { + x: vm.x, + y: vm.y + }; + } +}); + +var elements = {}; +var Arc = element_arc; +var Line = element_line; +var Point = element_point; +var Rectangle = element_rectangle; +elements.Arc = Arc; +elements.Line = Line; +elements.Point = Point; +elements.Rectangle = Rectangle; + +var deprecated = helpers$1._deprecated; +var valueOrDefault$3 = helpers$1.valueOrDefault; + +core_defaults._set('bar', { + hover: { + mode: 'label' + }, + + scales: { + xAxes: [{ + type: 'category', + offset: true, + gridLines: { + offsetGridLines: true + } + }], + + yAxes: [{ + type: 'linear' + }] + } +}); + +core_defaults._set('global', { + datasets: { + bar: { + categoryPercentage: 0.8, + barPercentage: 0.9 + } + } +}); + +/** + * Computes the "optimal" sample size to maintain bars equally sized while preventing overlap. + * @private + */ +function computeMinSampleSize(scale, pixels) { + var min = scale._length; + var prev, curr, i, ilen; + + for (i = 1, ilen = pixels.length; i < ilen; ++i) { + min = Math.min(min, Math.abs(pixels[i] - pixels[i - 1])); + } + + for (i = 0, ilen = scale.getTicks().length; i < ilen; ++i) { + curr = scale.getPixelForTick(i); + min = i > 0 ? Math.min(min, Math.abs(curr - prev)) : min; + prev = curr; + } + + return min; +} + +/** + * Computes an "ideal" category based on the absolute bar thickness or, if undefined or null, + * uses the smallest interval (see computeMinSampleSize) that prevents bar overlapping. This + * mode currently always generates bars equally sized (until we introduce scriptable options?). + * @private + */ +function computeFitCategoryTraits(index, ruler, options) { + var thickness = options.barThickness; + var count = ruler.stackCount; + var curr = ruler.pixels[index]; + var min = helpers$1.isNullOrUndef(thickness) + ? computeMinSampleSize(ruler.scale, ruler.pixels) + : -1; + var size, ratio; + + if (helpers$1.isNullOrUndef(thickness)) { + size = min * options.categoryPercentage; + ratio = options.barPercentage; + } else { + // When bar thickness is enforced, category and bar percentages are ignored. + // Note(SB): we could add support for relative bar thickness (e.g. barThickness: '50%') + // and deprecate barPercentage since this value is ignored when thickness is absolute. + size = thickness * count; + ratio = 1; + } + + return { + chunk: size / count, + ratio: ratio, + start: curr - (size / 2) + }; +} + +/** + * Computes an "optimal" category that globally arranges bars side by side (no gap when + * percentage options are 1), based on the previous and following categories. This mode + * generates bars with different widths when data are not evenly spaced. + * @private + */ +function computeFlexCategoryTraits(index, ruler, options) { + var pixels = ruler.pixels; + var curr = pixels[index]; + var prev = index > 0 ? pixels[index - 1] : null; + var next = index < pixels.length - 1 ? pixels[index + 1] : null; + var percent = options.categoryPercentage; + var start, size; + + if (prev === null) { + // first data: its size is double based on the next point or, + // if it's also the last data, we use the scale size. + prev = curr - (next === null ? ruler.end - ruler.start : next - curr); + } + + if (next === null) { + // last data: its size is also double based on the previous point. + next = curr + curr - prev; + } + + start = curr - (curr - Math.min(prev, next)) / 2 * percent; + size = Math.abs(next - prev) / 2 * percent; + + return { + chunk: size / ruler.stackCount, + ratio: options.barPercentage, + start: start + }; +} + +var controller_bar = core_datasetController.extend({ + + dataElementType: elements.Rectangle, + + /** + * @private + */ + _dataElementOptions: [ + 'backgroundColor', + 'borderColor', + 'borderSkipped', + 'borderWidth', + 'barPercentage', + 'barThickness', + 'categoryPercentage', + 'maxBarThickness', + 'minBarLength' + ], + + initialize: function() { + var me = this; + var meta, scaleOpts; + + core_datasetController.prototype.initialize.apply(me, arguments); + + meta = me.getMeta(); + meta.stack = me.getDataset().stack; + meta.bar = true; + + scaleOpts = me._getIndexScale().options; + deprecated('bar chart', scaleOpts.barPercentage, 'scales.[x/y]Axes.barPercentage', 'dataset.barPercentage'); + deprecated('bar chart', scaleOpts.barThickness, 'scales.[x/y]Axes.barThickness', 'dataset.barThickness'); + deprecated('bar chart', scaleOpts.categoryPercentage, 'scales.[x/y]Axes.categoryPercentage', 'dataset.categoryPercentage'); + deprecated('bar chart', me._getValueScale().options.minBarLength, 'scales.[x/y]Axes.minBarLength', 'dataset.minBarLength'); + deprecated('bar chart', scaleOpts.maxBarThickness, 'scales.[x/y]Axes.maxBarThickness', 'dataset.maxBarThickness'); + }, + + update: function(reset) { + var me = this; + var rects = me.getMeta().data; + var i, ilen; + + me._ruler = me.getRuler(); + + for (i = 0, ilen = rects.length; i < ilen; ++i) { + me.updateElement(rects[i], i, reset); + } + }, + + updateElement: function(rectangle, index, reset) { + var me = this; + var meta = me.getMeta(); + var dataset = me.getDataset(); + var options = me._resolveDataElementOptions(rectangle, index); + + rectangle._xScale = me.getScaleForId(meta.xAxisID); + rectangle._yScale = me.getScaleForId(meta.yAxisID); + rectangle._datasetIndex = me.index; + rectangle._index = index; + rectangle._model = { + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderSkipped: options.borderSkipped, + borderWidth: options.borderWidth, + datasetLabel: dataset.label, + label: me.chart.data.labels[index] + }; + + if (helpers$1.isArray(dataset.data[index])) { + rectangle._model.borderSkipped = null; + } + + me._updateElementGeometry(rectangle, index, reset, options); + + rectangle.pivot(); + }, + + /** + * @private + */ + _updateElementGeometry: function(rectangle, index, reset, options) { + var me = this; + var model = rectangle._model; + var vscale = me._getValueScale(); + var base = vscale.getBasePixel(); + var horizontal = vscale.isHorizontal(); + var ruler = me._ruler || me.getRuler(); + var vpixels = me.calculateBarValuePixels(me.index, index, options); + var ipixels = me.calculateBarIndexPixels(me.index, index, ruler, options); + + model.horizontal = horizontal; + model.base = reset ? base : vpixels.base; + model.x = horizontal ? reset ? base : vpixels.head : ipixels.center; + model.y = horizontal ? ipixels.center : reset ? base : vpixels.head; + model.height = horizontal ? ipixels.size : undefined; + model.width = horizontal ? undefined : ipixels.size; + }, + + /** + * Returns the stacks based on groups and bar visibility. + * @param {number} [last] - The dataset index + * @returns {string[]} The list of stack IDs + * @private + */ + _getStacks: function(last) { + var me = this; + var scale = me._getIndexScale(); + var metasets = scale._getMatchingVisibleMetas(me._type); + var stacked = scale.options.stacked; + var ilen = metasets.length; + var stacks = []; + var i, meta; + + for (i = 0; i < ilen; ++i) { + meta = metasets[i]; + // stacked | meta.stack + // | found | not found | undefined + // false | x | x | x + // true | | x | + // undefined | | x | x + if (stacked === false || stacks.indexOf(meta.stack) === -1 || + (stacked === undefined && meta.stack === undefined)) { + stacks.push(meta.stack); + } + if (meta.index === last) { + break; + } + } + + return stacks; + }, + + /** + * Returns the effective number of stacks based on groups and bar visibility. + * @private + */ + getStackCount: function() { + return this._getStacks().length; + }, + + /** + * Returns the stack index for the given dataset based on groups and bar visibility. + * @param {number} [datasetIndex] - The dataset index + * @param {string} [name] - The stack name to find + * @returns {number} The stack index + * @private + */ + getStackIndex: function(datasetIndex, name) { + var stacks = this._getStacks(datasetIndex); + var index = (name !== undefined) + ? stacks.indexOf(name) + : -1; // indexOf returns -1 if element is not present + + return (index === -1) + ? stacks.length - 1 + : index; + }, + + /** + * @private + */ + getRuler: function() { + var me = this; + var scale = me._getIndexScale(); + var pixels = []; + var i, ilen; + + for (i = 0, ilen = me.getMeta().data.length; i < ilen; ++i) { + pixels.push(scale.getPixelForValue(null, i, me.index)); + } + + return { + pixels: pixels, + start: scale._startPixel, + end: scale._endPixel, + stackCount: me.getStackCount(), + scale: scale + }; + }, + + /** + * Note: pixel values are not clamped to the scale area. + * @private + */ + calculateBarValuePixels: function(datasetIndex, index, options) { + var me = this; + var chart = me.chart; + var scale = me._getValueScale(); + var isHorizontal = scale.isHorizontal(); + var datasets = chart.data.datasets; + var metasets = scale._getMatchingVisibleMetas(me._type); + var value = scale._parseValue(datasets[datasetIndex].data[index]); + var minBarLength = options.minBarLength; + var stacked = scale.options.stacked; + var stack = me.getMeta().stack; + var start = value.start === undefined ? 0 : value.max >= 0 && value.min >= 0 ? value.min : value.max; + var length = value.start === undefined ? value.end : value.max >= 0 && value.min >= 0 ? value.max - value.min : value.min - value.max; + var ilen = metasets.length; + var i, imeta, ivalue, base, head, size, stackLength; + + if (stacked || (stacked === undefined && stack !== undefined)) { + for (i = 0; i < ilen; ++i) { + imeta = metasets[i]; + + if (imeta.index === datasetIndex) { + break; + } + + if (imeta.stack === stack) { + stackLength = scale._parseValue(datasets[imeta.index].data[index]); + ivalue = stackLength.start === undefined ? stackLength.end : stackLength.min >= 0 && stackLength.max >= 0 ? stackLength.max : stackLength.min; + + if ((value.min < 0 && ivalue < 0) || (value.max >= 0 && ivalue > 0)) { + start += ivalue; + } + } + } + } + + base = scale.getPixelForValue(start); + head = scale.getPixelForValue(start + length); + size = head - base; + + if (minBarLength !== undefined && Math.abs(size) < minBarLength) { + size = minBarLength; + if (length >= 0 && !isHorizontal || length < 0 && isHorizontal) { + head = base - minBarLength; + } else { + head = base + minBarLength; + } + } + + return { + size: size, + base: base, + head: head, + center: head + size / 2 + }; + }, + + /** + * @private + */ + calculateBarIndexPixels: function(datasetIndex, index, ruler, options) { + var me = this; + var range = options.barThickness === 'flex' + ? computeFlexCategoryTraits(index, ruler, options) + : computeFitCategoryTraits(index, ruler, options); + + var stackIndex = me.getStackIndex(datasetIndex, me.getMeta().stack); + var center = range.start + (range.chunk * stackIndex) + (range.chunk / 2); + var size = Math.min( + valueOrDefault$3(options.maxBarThickness, Infinity), + range.chunk * range.ratio); + + return { + base: center - size / 2, + head: center + size / 2, + center: center, + size: size + }; + }, + + draw: function() { + var me = this; + var chart = me.chart; + var scale = me._getValueScale(); + var rects = me.getMeta().data; + var dataset = me.getDataset(); + var ilen = rects.length; + var i = 0; + + helpers$1.canvas.clipArea(chart.ctx, chart.chartArea); + + for (; i < ilen; ++i) { + var val = scale._parseValue(dataset.data[i]); + if (!isNaN(val.min) && !isNaN(val.max)) { + rects[i].draw(); + } + } + + helpers$1.canvas.unclipArea(chart.ctx); + }, + + /** + * @private + */ + _resolveDataElementOptions: function() { + var me = this; + var values = helpers$1.extend({}, core_datasetController.prototype._resolveDataElementOptions.apply(me, arguments)); + var indexOpts = me._getIndexScale().options; + var valueOpts = me._getValueScale().options; + + values.barPercentage = valueOrDefault$3(indexOpts.barPercentage, values.barPercentage); + values.barThickness = valueOrDefault$3(indexOpts.barThickness, values.barThickness); + values.categoryPercentage = valueOrDefault$3(indexOpts.categoryPercentage, values.categoryPercentage); + values.maxBarThickness = valueOrDefault$3(indexOpts.maxBarThickness, values.maxBarThickness); + values.minBarLength = valueOrDefault$3(valueOpts.minBarLength, values.minBarLength); + + return values; + } + +}); + +var valueOrDefault$4 = helpers$1.valueOrDefault; +var resolve$1 = helpers$1.options.resolve; + +core_defaults._set('bubble', { + hover: { + mode: 'single' + }, + + scales: { + xAxes: [{ + type: 'linear', // bubble should probably use a linear scale by default + position: 'bottom', + id: 'x-axis-0' // need an ID so datasets can reference the scale + }], + yAxes: [{ + type: 'linear', + position: 'left', + id: 'y-axis-0' + }] + }, + + tooltips: { + callbacks: { + title: function() { + // Title doesn't make sense for scatter since we format the data as a point + return ''; + }, + label: function(item, data) { + var datasetLabel = data.datasets[item.datasetIndex].label || ''; + var dataPoint = data.datasets[item.datasetIndex].data[item.index]; + return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' + dataPoint.r + ')'; + } + } + } +}); + +var controller_bubble = core_datasetController.extend({ + /** + * @protected + */ + dataElementType: elements.Point, + + /** + * @private + */ + _dataElementOptions: [ + 'backgroundColor', + 'borderColor', + 'borderWidth', + 'hoverBackgroundColor', + 'hoverBorderColor', + 'hoverBorderWidth', + 'hoverRadius', + 'hitRadius', + 'pointStyle', + 'rotation' + ], + + /** + * @protected + */ + update: function(reset) { + var me = this; + var meta = me.getMeta(); + var points = meta.data; + + // Update Points + helpers$1.each(points, function(point, index) { + me.updateElement(point, index, reset); + }); + }, + + /** + * @protected + */ + updateElement: function(point, index, reset) { + var me = this; + var meta = me.getMeta(); + var custom = point.custom || {}; + var xScale = me.getScaleForId(meta.xAxisID); + var yScale = me.getScaleForId(meta.yAxisID); + var options = me._resolveDataElementOptions(point, index); + var data = me.getDataset().data[index]; + var dsIndex = me.index; + + var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex); + var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex); + + point._xScale = xScale; + point._yScale = yScale; + point._options = options; + point._datasetIndex = dsIndex; + point._index = index; + point._model = { + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + hitRadius: options.hitRadius, + pointStyle: options.pointStyle, + rotation: options.rotation, + radius: reset ? 0 : options.radius, + skip: custom.skip || isNaN(x) || isNaN(y), + x: x, + y: y, + }; + + point.pivot(); + }, + + /** + * @protected + */ + setHoverStyle: function(point) { + var model = point._model; + var options = point._options; + var getHoverColor = helpers$1.getHoverColor; + + point.$previousStyle = { + backgroundColor: model.backgroundColor, + borderColor: model.borderColor, + borderWidth: model.borderWidth, + radius: model.radius + }; + + model.backgroundColor = valueOrDefault$4(options.hoverBackgroundColor, getHoverColor(options.backgroundColor)); + model.borderColor = valueOrDefault$4(options.hoverBorderColor, getHoverColor(options.borderColor)); + model.borderWidth = valueOrDefault$4(options.hoverBorderWidth, options.borderWidth); + model.radius = options.radius + options.hoverRadius; + }, + + /** + * @private + */ + _resolveDataElementOptions: function(point, index) { + var me = this; + var chart = me.chart; + var dataset = me.getDataset(); + var custom = point.custom || {}; + var data = dataset.data[index] || {}; + var values = core_datasetController.prototype._resolveDataElementOptions.apply(me, arguments); + + // Scriptable options + var context = { + chart: chart, + dataIndex: index, + dataset: dataset, + datasetIndex: me.index + }; + + // In case values were cached (and thus frozen), we need to clone the values + if (me._cachedDataOpts === values) { + values = helpers$1.extend({}, values); + } + + // Custom radius resolution + values.radius = resolve$1([ + custom.radius, + data.r, + me._config.radius, + chart.options.elements.point.radius + ], context, index); + + return values; + } +}); + +var valueOrDefault$5 = helpers$1.valueOrDefault; + +var PI$1 = Math.PI; +var DOUBLE_PI$1 = PI$1 * 2; +var HALF_PI$1 = PI$1 / 2; + +core_defaults._set('doughnut', { + animation: { + // Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, + // Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false + }, + hover: { + mode: 'single' + }, + legendCallback: function(chart) { + var list = document.createElement('ul'); + var data = chart.data; + var datasets = data.datasets; + var labels = data.labels; + var i, ilen, listItem, listItemSpan; + + list.setAttribute('class', chart.id + '-legend'); + if (datasets.length) { + for (i = 0, ilen = datasets[0].data.length; i < ilen; ++i) { + listItem = list.appendChild(document.createElement('li')); + listItemSpan = listItem.appendChild(document.createElement('span')); + listItemSpan.style.backgroundColor = datasets[0].backgroundColor[i]; + if (labels[i]) { + listItem.appendChild(document.createTextNode(labels[i])); + } + } + } + + return list.outerHTML; + }, + legend: { + labels: { + generateLabels: function(chart) { + var data = chart.data; + if (data.labels.length && data.datasets.length) { + return data.labels.map(function(label, i) { + var meta = chart.getDatasetMeta(0); + var style = meta.controller.getStyle(i); + + return { + text: label, + fillStyle: style.backgroundColor, + strokeStyle: style.borderColor, + lineWidth: style.borderWidth, + hidden: isNaN(data.datasets[0].data[i]) || meta.data[i].hidden, + + // Extra data used for toggling the correct item + index: i + }; + }); + } + return []; + } + }, + + onClick: function(e, legendItem) { + var index = legendItem.index; + var chart = this.chart; + var i, ilen, meta; + + for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) { + meta = chart.getDatasetMeta(i); + // toggle visibility of index if exists + if (meta.data[index]) { + meta.data[index].hidden = !meta.data[index].hidden; + } + } + + chart.update(); + } + }, + + // The percentage of the chart that we cut out of the middle. + cutoutPercentage: 50, + + // The rotation of the chart, where the first data arc begins. + rotation: -HALF_PI$1, + + // The total circumference of the chart. + circumference: DOUBLE_PI$1, + + // Need to override these to give a nice default + tooltips: { + callbacks: { + title: function() { + return ''; + }, + label: function(tooltipItem, data) { + var dataLabel = data.labels[tooltipItem.index]; + var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; + + if (helpers$1.isArray(dataLabel)) { + // show value on first line of multiline label + // need to clone because we are changing the value + dataLabel = dataLabel.slice(); + dataLabel[0] += value; + } else { + dataLabel += value; + } + + return dataLabel; + } + } + } +}); + +var controller_doughnut = core_datasetController.extend({ + + dataElementType: elements.Arc, + + linkScales: helpers$1.noop, + + /** + * @private + */ + _dataElementOptions: [ + 'backgroundColor', + 'borderColor', + 'borderWidth', + 'borderAlign', + 'hoverBackgroundColor', + 'hoverBorderColor', + 'hoverBorderWidth', + ], + + // Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly + getRingIndex: function(datasetIndex) { + var ringIndex = 0; + + for (var j = 0; j < datasetIndex; ++j) { + if (this.chart.isDatasetVisible(j)) { + ++ringIndex; + } + } + + return ringIndex; + }, + + update: function(reset) { + var me = this; + var chart = me.chart; + var chartArea = chart.chartArea; + var opts = chart.options; + var ratioX = 1; + var ratioY = 1; + var offsetX = 0; + var offsetY = 0; + var meta = me.getMeta(); + var arcs = meta.data; + var cutout = opts.cutoutPercentage / 100 || 0; + var circumference = opts.circumference; + var chartWeight = me._getRingWeight(me.index); + var maxWidth, maxHeight, i, ilen; + + // If the chart's circumference isn't a full circle, calculate size as a ratio of the width/height of the arc + if (circumference < DOUBLE_PI$1) { + var startAngle = opts.rotation % DOUBLE_PI$1; + startAngle += startAngle >= PI$1 ? -DOUBLE_PI$1 : startAngle < -PI$1 ? DOUBLE_PI$1 : 0; + var endAngle = startAngle + circumference; + var startX = Math.cos(startAngle); + var startY = Math.sin(startAngle); + var endX = Math.cos(endAngle); + var endY = Math.sin(endAngle); + var contains0 = (startAngle <= 0 && endAngle >= 0) || endAngle >= DOUBLE_PI$1; + var contains90 = (startAngle <= HALF_PI$1 && endAngle >= HALF_PI$1) || endAngle >= DOUBLE_PI$1 + HALF_PI$1; + var contains180 = startAngle === -PI$1 || endAngle >= PI$1; + var contains270 = (startAngle <= -HALF_PI$1 && endAngle >= -HALF_PI$1) || endAngle >= PI$1 + HALF_PI$1; + var minX = contains180 ? -1 : Math.min(startX, startX * cutout, endX, endX * cutout); + var minY = contains270 ? -1 : Math.min(startY, startY * cutout, endY, endY * cutout); + var maxX = contains0 ? 1 : Math.max(startX, startX * cutout, endX, endX * cutout); + var maxY = contains90 ? 1 : Math.max(startY, startY * cutout, endY, endY * cutout); + ratioX = (maxX - minX) / 2; + ratioY = (maxY - minY) / 2; + offsetX = -(maxX + minX) / 2; + offsetY = -(maxY + minY) / 2; + } + + for (i = 0, ilen = arcs.length; i < ilen; ++i) { + arcs[i]._options = me._resolveDataElementOptions(arcs[i], i); + } + + chart.borderWidth = me.getMaxBorderWidth(); + maxWidth = (chartArea.right - chartArea.left - chart.borderWidth) / ratioX; + maxHeight = (chartArea.bottom - chartArea.top - chart.borderWidth) / ratioY; + chart.outerRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0); + chart.innerRadius = Math.max(chart.outerRadius * cutout, 0); + chart.radiusLength = (chart.outerRadius - chart.innerRadius) / (me._getVisibleDatasetWeightTotal() || 1); + chart.offsetX = offsetX * chart.outerRadius; + chart.offsetY = offsetY * chart.outerRadius; + + meta.total = me.calculateTotal(); + + me.outerRadius = chart.outerRadius - chart.radiusLength * me._getRingWeightOffset(me.index); + me.innerRadius = Math.max(me.outerRadius - chart.radiusLength * chartWeight, 0); + + for (i = 0, ilen = arcs.length; i < ilen; ++i) { + me.updateElement(arcs[i], i, reset); + } + }, + + updateElement: function(arc, index, reset) { + var me = this; + var chart = me.chart; + var chartArea = chart.chartArea; + var opts = chart.options; + var animationOpts = opts.animation; + var centerX = (chartArea.left + chartArea.right) / 2; + var centerY = (chartArea.top + chartArea.bottom) / 2; + var startAngle = opts.rotation; // non reset case handled later + var endAngle = opts.rotation; // non reset case handled later + var dataset = me.getDataset(); + var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumference / DOUBLE_PI$1); + var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius; + var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius; + var options = arc._options || {}; + + helpers$1.extend(arc, { + // Utility + _datasetIndex: me.index, + _index: index, + + // Desired view properties + _model: { + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + borderAlign: options.borderAlign, + x: centerX + chart.offsetX, + y: centerY + chart.offsetY, + startAngle: startAngle, + endAngle: endAngle, + circumference: circumference, + outerRadius: outerRadius, + innerRadius: innerRadius, + label: helpers$1.valueAtIndexOrDefault(dataset.label, index, chart.data.labels[index]) + } + }); + + var model = arc._model; + + // Set correct angles if not resetting + if (!reset || !animationOpts.animateRotate) { + if (index === 0) { + model.startAngle = opts.rotation; + } else { + model.startAngle = me.getMeta().data[index - 1]._model.endAngle; + } + + model.endAngle = model.startAngle + model.circumference; + } + + arc.pivot(); + }, + + calculateTotal: function() { + var dataset = this.getDataset(); + var meta = this.getMeta(); + var total = 0; + var value; + + helpers$1.each(meta.data, function(element, index) { + value = dataset.data[index]; + if (!isNaN(value) && !element.hidden) { + total += Math.abs(value); + } + }); + + /* if (total === 0) { + total = NaN; + }*/ + + return total; + }, + + calculateCircumference: function(value) { + var total = this.getMeta().total; + if (total > 0 && !isNaN(value)) { + return DOUBLE_PI$1 * (Math.abs(value) / total); + } + return 0; + }, + + // gets the max border or hover width to properly scale pie charts + getMaxBorderWidth: function(arcs) { + var me = this; + var max = 0; + var chart = me.chart; + var i, ilen, meta, arc, controller, options, borderWidth, hoverWidth; + + if (!arcs) { + // Find the outmost visible dataset + for (i = 0, ilen = chart.data.datasets.length; i < ilen; ++i) { + if (chart.isDatasetVisible(i)) { + meta = chart.getDatasetMeta(i); + arcs = meta.data; + if (i !== me.index) { + controller = meta.controller; + } + break; + } + } + } + + if (!arcs) { + return 0; + } + + for (i = 0, ilen = arcs.length; i < ilen; ++i) { + arc = arcs[i]; + if (controller) { + controller._configure(); + options = controller._resolveDataElementOptions(arc, i); + } else { + options = arc._options; + } + if (options.borderAlign !== 'inner') { + borderWidth = options.borderWidth; + hoverWidth = options.hoverBorderWidth; + + max = borderWidth > max ? borderWidth : max; + max = hoverWidth > max ? hoverWidth : max; + } + } + return max; + }, + + /** + * @protected + */ + setHoverStyle: function(arc) { + var model = arc._model; + var options = arc._options; + var getHoverColor = helpers$1.getHoverColor; + + arc.$previousStyle = { + backgroundColor: model.backgroundColor, + borderColor: model.borderColor, + borderWidth: model.borderWidth, + }; + + model.backgroundColor = valueOrDefault$5(options.hoverBackgroundColor, getHoverColor(options.backgroundColor)); + model.borderColor = valueOrDefault$5(options.hoverBorderColor, getHoverColor(options.borderColor)); + model.borderWidth = valueOrDefault$5(options.hoverBorderWidth, options.borderWidth); + }, + + /** + * Get radius length offset of the dataset in relation to the visible datasets weights. This allows determining the inner and outer radius correctly + * @private + */ + _getRingWeightOffset: function(datasetIndex) { + var ringWeightOffset = 0; + + for (var i = 0; i < datasetIndex; ++i) { + if (this.chart.isDatasetVisible(i)) { + ringWeightOffset += this._getRingWeight(i); + } + } + + return ringWeightOffset; + }, + + /** + * @private + */ + _getRingWeight: function(dataSetIndex) { + return Math.max(valueOrDefault$5(this.chart.data.datasets[dataSetIndex].weight, 1), 0); + }, + + /** + * Returns the sum of all visibile data set weights. This value can be 0. + * @private + */ + _getVisibleDatasetWeightTotal: function() { + return this._getRingWeightOffset(this.chart.data.datasets.length); + } +}); + +core_defaults._set('horizontalBar', { + hover: { + mode: 'index', + axis: 'y' + }, + + scales: { + xAxes: [{ + type: 'linear', + position: 'bottom' + }], + + yAxes: [{ + type: 'category', + position: 'left', + offset: true, + gridLines: { + offsetGridLines: true + } + }] + }, + + elements: { + rectangle: { + borderSkipped: 'left' + } + }, + + tooltips: { + mode: 'index', + axis: 'y' + } +}); + +core_defaults._set('global', { + datasets: { + horizontalBar: { + categoryPercentage: 0.8, + barPercentage: 0.9 + } + } +}); + +var controller_horizontalBar = controller_bar.extend({ + /** + * @private + */ + _getValueScaleId: function() { + return this.getMeta().xAxisID; + }, + + /** + * @private + */ + _getIndexScaleId: function() { + return this.getMeta().yAxisID; + } +}); + +var valueOrDefault$6 = helpers$1.valueOrDefault; +var resolve$2 = helpers$1.options.resolve; +var isPointInArea = helpers$1.canvas._isPointInArea; + +core_defaults._set('line', { + showLines: true, + spanGaps: false, + + hover: { + mode: 'label' + }, + + scales: { + xAxes: [{ + type: 'category', + id: 'x-axis-0' + }], + yAxes: [{ + type: 'linear', + id: 'y-axis-0' + }] + } +}); + +function scaleClip(scale, halfBorderWidth) { + var tickOpts = scale && scale.options.ticks || {}; + var reverse = tickOpts.reverse; + var min = tickOpts.min === undefined ? halfBorderWidth : 0; + var max = tickOpts.max === undefined ? halfBorderWidth : 0; + return { + start: reverse ? max : min, + end: reverse ? min : max + }; +} + +function defaultClip(xScale, yScale, borderWidth) { + var halfBorderWidth = borderWidth / 2; + var x = scaleClip(xScale, halfBorderWidth); + var y = scaleClip(yScale, halfBorderWidth); + + return { + top: y.end, + right: x.end, + bottom: y.start, + left: x.start + }; +} + +function toClip(value) { + var t, r, b, l; + + if (helpers$1.isObject(value)) { + t = value.top; + r = value.right; + b = value.bottom; + l = value.left; + } else { + t = r = b = l = value; + } + + return { + top: t, + right: r, + bottom: b, + left: l + }; +} + + +var controller_line = core_datasetController.extend({ + + datasetElementType: elements.Line, + + dataElementType: elements.Point, + + /** + * @private + */ + _datasetElementOptions: [ + 'backgroundColor', + 'borderCapStyle', + 'borderColor', + 'borderDash', + 'borderDashOffset', + 'borderJoinStyle', + 'borderWidth', + 'cubicInterpolationMode', + 'fill' + ], + + /** + * @private + */ + _dataElementOptions: { + backgroundColor: 'pointBackgroundColor', + borderColor: 'pointBorderColor', + borderWidth: 'pointBorderWidth', + hitRadius: 'pointHitRadius', + hoverBackgroundColor: 'pointHoverBackgroundColor', + hoverBorderColor: 'pointHoverBorderColor', + hoverBorderWidth: 'pointHoverBorderWidth', + hoverRadius: 'pointHoverRadius', + pointStyle: 'pointStyle', + radius: 'pointRadius', + rotation: 'pointRotation' + }, + + update: function(reset) { + var me = this; + var meta = me.getMeta(); + var line = meta.dataset; + var points = meta.data || []; + var options = me.chart.options; + var config = me._config; + var showLine = me._showLine = valueOrDefault$6(config.showLine, options.showLines); + var i, ilen; + + me._xScale = me.getScaleForId(meta.xAxisID); + me._yScale = me.getScaleForId(meta.yAxisID); + + // Update Line + if (showLine) { + // Compatibility: If the properties are defined with only the old name, use those values + if (config.tension !== undefined && config.lineTension === undefined) { + config.lineTension = config.tension; + } + + // Utility + line._scale = me._yScale; + line._datasetIndex = me.index; + // Data + line._children = points; + // Model + line._model = me._resolveDatasetElementOptions(line); + + line.pivot(); + } + + // Update Points + for (i = 0, ilen = points.length; i < ilen; ++i) { + me.updateElement(points[i], i, reset); + } + + if (showLine && line._model.tension !== 0) { + me.updateBezierControlPoints(); + } + + // Now pivot the point for animation + for (i = 0, ilen = points.length; i < ilen; ++i) { + points[i].pivot(); + } + }, + + updateElement: function(point, index, reset) { + var me = this; + var meta = me.getMeta(); + var custom = point.custom || {}; + var dataset = me.getDataset(); + var datasetIndex = me.index; + var value = dataset.data[index]; + var xScale = me._xScale; + var yScale = me._yScale; + var lineModel = meta.dataset._model; + var x, y; + + var options = me._resolveDataElementOptions(point, index); + + x = xScale.getPixelForValue(typeof value === 'object' ? value : NaN, index, datasetIndex); + y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex); + + // Utility + point._xScale = xScale; + point._yScale = yScale; + point._options = options; + point._datasetIndex = datasetIndex; + point._index = index; + + // Desired view properties + point._model = { + x: x, + y: y, + skip: custom.skip || isNaN(x) || isNaN(y), + // Appearance + radius: options.radius, + pointStyle: options.pointStyle, + rotation: options.rotation, + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + tension: valueOrDefault$6(custom.tension, lineModel ? lineModel.tension : 0), + steppedLine: lineModel ? lineModel.steppedLine : false, + // Tooltip + hitRadius: options.hitRadius + }; + }, + + /** + * @private + */ + _resolveDatasetElementOptions: function(element) { + var me = this; + var config = me._config; + var custom = element.custom || {}; + var options = me.chart.options; + var lineOptions = options.elements.line; + var values = core_datasetController.prototype._resolveDatasetElementOptions.apply(me, arguments); + + // The default behavior of lines is to break at null values, according + // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158 + // This option gives lines the ability to span gaps + values.spanGaps = valueOrDefault$6(config.spanGaps, options.spanGaps); + values.tension = valueOrDefault$6(config.lineTension, lineOptions.tension); + values.steppedLine = resolve$2([custom.steppedLine, config.steppedLine, lineOptions.stepped]); + values.clip = toClip(valueOrDefault$6(config.clip, defaultClip(me._xScale, me._yScale, values.borderWidth))); + + return values; + }, + + calculatePointY: function(value, index, datasetIndex) { + var me = this; + var chart = me.chart; + var yScale = me._yScale; + var sumPos = 0; + var sumNeg = 0; + var i, ds, dsMeta, stackedRightValue, rightValue, metasets, ilen; + + if (yScale.options.stacked) { + rightValue = +yScale.getRightValue(value); + metasets = chart._getSortedVisibleDatasetMetas(); + ilen = metasets.length; + + for (i = 0; i < ilen; ++i) { + dsMeta = metasets[i]; + if (dsMeta.index === datasetIndex) { + break; + } + + ds = chart.data.datasets[dsMeta.index]; + if (dsMeta.type === 'line' && dsMeta.yAxisID === yScale.id) { + stackedRightValue = +yScale.getRightValue(ds.data[index]); + if (stackedRightValue < 0) { + sumNeg += stackedRightValue || 0; + } else { + sumPos += stackedRightValue || 0; + } + } + } + + if (rightValue < 0) { + return yScale.getPixelForValue(sumNeg + rightValue); + } + return yScale.getPixelForValue(sumPos + rightValue); + } + return yScale.getPixelForValue(value); + }, + + updateBezierControlPoints: function() { + var me = this; + var chart = me.chart; + var meta = me.getMeta(); + var lineModel = meta.dataset._model; + var area = chart.chartArea; + var points = meta.data || []; + var i, ilen, model, controlPoints; + + // Only consider points that are drawn in case the spanGaps option is used + if (lineModel.spanGaps) { + points = points.filter(function(pt) { + return !pt._model.skip; + }); + } + + function capControlPoint(pt, min, max) { + return Math.max(Math.min(pt, max), min); + } + + if (lineModel.cubicInterpolationMode === 'monotone') { + helpers$1.splineCurveMonotone(points); + } else { + for (i = 0, ilen = points.length; i < ilen; ++i) { + model = points[i]._model; + controlPoints = helpers$1.splineCurve( + helpers$1.previousItem(points, i)._model, + model, + helpers$1.nextItem(points, i)._model, + lineModel.tension + ); + model.controlPointPreviousX = controlPoints.previous.x; + model.controlPointPreviousY = controlPoints.previous.y; + model.controlPointNextX = controlPoints.next.x; + model.controlPointNextY = controlPoints.next.y; + } + } + + if (chart.options.elements.line.capBezierPoints) { + for (i = 0, ilen = points.length; i < ilen; ++i) { + model = points[i]._model; + if (isPointInArea(model, area)) { + if (i > 0 && isPointInArea(points[i - 1]._model, area)) { + model.controlPointPreviousX = capControlPoint(model.controlPointPreviousX, area.left, area.right); + model.controlPointPreviousY = capControlPoint(model.controlPointPreviousY, area.top, area.bottom); + } + if (i < points.length - 1 && isPointInArea(points[i + 1]._model, area)) { + model.controlPointNextX = capControlPoint(model.controlPointNextX, area.left, area.right); + model.controlPointNextY = capControlPoint(model.controlPointNextY, area.top, area.bottom); + } + } + } + } + }, + + draw: function() { + var me = this; + var chart = me.chart; + var meta = me.getMeta(); + var points = meta.data || []; + var area = chart.chartArea; + var canvas = chart.canvas; + var i = 0; + var ilen = points.length; + var clip; + + if (me._showLine) { + clip = meta.dataset._model.clip; + + helpers$1.canvas.clipArea(chart.ctx, { + left: clip.left === false ? 0 : area.left - clip.left, + right: clip.right === false ? canvas.width : area.right + clip.right, + top: clip.top === false ? 0 : area.top - clip.top, + bottom: clip.bottom === false ? canvas.height : area.bottom + clip.bottom + }); + + meta.dataset.draw(); + + helpers$1.canvas.unclipArea(chart.ctx); + } + + // Draw the points + for (; i < ilen; ++i) { + points[i].draw(area); + } + }, + + /** + * @protected + */ + setHoverStyle: function(point) { + var model = point._model; + var options = point._options; + var getHoverColor = helpers$1.getHoverColor; + + point.$previousStyle = { + backgroundColor: model.backgroundColor, + borderColor: model.borderColor, + borderWidth: model.borderWidth, + radius: model.radius + }; + + model.backgroundColor = valueOrDefault$6(options.hoverBackgroundColor, getHoverColor(options.backgroundColor)); + model.borderColor = valueOrDefault$6(options.hoverBorderColor, getHoverColor(options.borderColor)); + model.borderWidth = valueOrDefault$6(options.hoverBorderWidth, options.borderWidth); + model.radius = valueOrDefault$6(options.hoverRadius, options.radius); + }, +}); + +var resolve$3 = helpers$1.options.resolve; + +core_defaults._set('polarArea', { + scale: { + type: 'radialLinear', + angleLines: { + display: false + }, + gridLines: { + circular: true + }, + pointLabels: { + display: false + }, + ticks: { + beginAtZero: true + } + }, + + // Boolean - Whether to animate the rotation of the chart + animation: { + animateRotate: true, + animateScale: true + }, + + startAngle: -0.5 * Math.PI, + legendCallback: function(chart) { + var list = document.createElement('ul'); + var data = chart.data; + var datasets = data.datasets; + var labels = data.labels; + var i, ilen, listItem, listItemSpan; + + list.setAttribute('class', chart.id + '-legend'); + if (datasets.length) { + for (i = 0, ilen = datasets[0].data.length; i < ilen; ++i) { + listItem = list.appendChild(document.createElement('li')); + listItemSpan = listItem.appendChild(document.createElement('span')); + listItemSpan.style.backgroundColor = datasets[0].backgroundColor[i]; + if (labels[i]) { + listItem.appendChild(document.createTextNode(labels[i])); + } + } + } + + return list.outerHTML; + }, + legend: { + labels: { + generateLabels: function(chart) { + var data = chart.data; + if (data.labels.length && data.datasets.length) { + return data.labels.map(function(label, i) { + var meta = chart.getDatasetMeta(0); + var style = meta.controller.getStyle(i); + + return { + text: label, + fillStyle: style.backgroundColor, + strokeStyle: style.borderColor, + lineWidth: style.borderWidth, + hidden: isNaN(data.datasets[0].data[i]) || meta.data[i].hidden, + + // Extra data used for toggling the correct item + index: i + }; + }); + } + return []; + } + }, + + onClick: function(e, legendItem) { + var index = legendItem.index; + var chart = this.chart; + var i, ilen, meta; + + for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) { + meta = chart.getDatasetMeta(i); + meta.data[index].hidden = !meta.data[index].hidden; + } + + chart.update(); + } + }, + + // Need to override these to give a nice default + tooltips: { + callbacks: { + title: function() { + return ''; + }, + label: function(item, data) { + return data.labels[item.index] + ': ' + item.yLabel; + } + } + } +}); + +var controller_polarArea = core_datasetController.extend({ + + dataElementType: elements.Arc, + + linkScales: helpers$1.noop, + + /** + * @private + */ + _dataElementOptions: [ + 'backgroundColor', + 'borderColor', + 'borderWidth', + 'borderAlign', + 'hoverBackgroundColor', + 'hoverBorderColor', + 'hoverBorderWidth', + ], + + /** + * @private + */ + _getIndexScaleId: function() { + return this.chart.scale.id; + }, + + /** + * @private + */ + _getValueScaleId: function() { + return this.chart.scale.id; + }, + + update: function(reset) { + var me = this; + var dataset = me.getDataset(); + var meta = me.getMeta(); + var start = me.chart.options.startAngle || 0; + var starts = me._starts = []; + var angles = me._angles = []; + var arcs = meta.data; + var i, ilen, angle; + + me._updateRadius(); + + meta.count = me.countVisibleElements(); + + for (i = 0, ilen = dataset.data.length; i < ilen; i++) { + starts[i] = start; + angle = me._computeAngle(i); + angles[i] = angle; + start += angle; + } + + for (i = 0, ilen = arcs.length; i < ilen; ++i) { + arcs[i]._options = me._resolveDataElementOptions(arcs[i], i); + me.updateElement(arcs[i], i, reset); + } + }, + + /** + * @private + */ + _updateRadius: function() { + var me = this; + var chart = me.chart; + var chartArea = chart.chartArea; + var opts = chart.options; + var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top); + + chart.outerRadius = Math.max(minSize / 2, 0); + chart.innerRadius = Math.max(opts.cutoutPercentage ? (chart.outerRadius / 100) * (opts.cutoutPercentage) : 1, 0); + chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount(); + + me.outerRadius = chart.outerRadius - (chart.radiusLength * me.index); + me.innerRadius = me.outerRadius - chart.radiusLength; + }, + + updateElement: function(arc, index, reset) { + var me = this; + var chart = me.chart; + var dataset = me.getDataset(); + var opts = chart.options; + var animationOpts = opts.animation; + var scale = chart.scale; + var labels = chart.data.labels; + + var centerX = scale.xCenter; + var centerY = scale.yCenter; + + // var negHalfPI = -0.5 * Math.PI; + var datasetStartAngle = opts.startAngle; + var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]); + var startAngle = me._starts[index]; + var endAngle = startAngle + (arc.hidden ? 0 : me._angles[index]); + + var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]); + var options = arc._options || {}; + + helpers$1.extend(arc, { + // Utility + _datasetIndex: me.index, + _index: index, + _scale: scale, + + // Desired view properties + _model: { + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + borderAlign: options.borderAlign, + x: centerX, + y: centerY, + innerRadius: 0, + outerRadius: reset ? resetRadius : distance, + startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle, + endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle, + label: helpers$1.valueAtIndexOrDefault(labels, index, labels[index]) + } + }); + + arc.pivot(); + }, + + countVisibleElements: function() { + var dataset = this.getDataset(); + var meta = this.getMeta(); + var count = 0; + + helpers$1.each(meta.data, function(element, index) { + if (!isNaN(dataset.data[index]) && !element.hidden) { + count++; + } + }); + + return count; + }, + + /** + * @protected + */ + setHoverStyle: function(arc) { + var model = arc._model; + var options = arc._options; + var getHoverColor = helpers$1.getHoverColor; + var valueOrDefault = helpers$1.valueOrDefault; + + arc.$previousStyle = { + backgroundColor: model.backgroundColor, + borderColor: model.borderColor, + borderWidth: model.borderWidth, + }; + + model.backgroundColor = valueOrDefault(options.hoverBackgroundColor, getHoverColor(options.backgroundColor)); + model.borderColor = valueOrDefault(options.hoverBorderColor, getHoverColor(options.borderColor)); + model.borderWidth = valueOrDefault(options.hoverBorderWidth, options.borderWidth); + }, + + /** + * @private + */ + _computeAngle: function(index) { + var me = this; + var count = this.getMeta().count; + var dataset = me.getDataset(); + var meta = me.getMeta(); + + if (isNaN(dataset.data[index]) || meta.data[index].hidden) { + return 0; + } + + // Scriptable options + var context = { + chart: me.chart, + dataIndex: index, + dataset: dataset, + datasetIndex: me.index + }; + + return resolve$3([ + me.chart.options.elements.arc.angle, + (2 * Math.PI) / count + ], context, index); + } +}); + +core_defaults._set('pie', helpers$1.clone(core_defaults.doughnut)); +core_defaults._set('pie', { + cutoutPercentage: 0 +}); + +// Pie charts are Doughnut chart with different defaults +var controller_pie = controller_doughnut; + +var valueOrDefault$7 = helpers$1.valueOrDefault; + +core_defaults._set('radar', { + spanGaps: false, + scale: { + type: 'radialLinear' + }, + elements: { + line: { + fill: 'start', + tension: 0 // no bezier in radar + } + } +}); + +var controller_radar = core_datasetController.extend({ + datasetElementType: elements.Line, + + dataElementType: elements.Point, + + linkScales: helpers$1.noop, + + /** + * @private + */ + _datasetElementOptions: [ + 'backgroundColor', + 'borderWidth', + 'borderColor', + 'borderCapStyle', + 'borderDash', + 'borderDashOffset', + 'borderJoinStyle', + 'fill' + ], + + /** + * @private + */ + _dataElementOptions: { + backgroundColor: 'pointBackgroundColor', + borderColor: 'pointBorderColor', + borderWidth: 'pointBorderWidth', + hitRadius: 'pointHitRadius', + hoverBackgroundColor: 'pointHoverBackgroundColor', + hoverBorderColor: 'pointHoverBorderColor', + hoverBorderWidth: 'pointHoverBorderWidth', + hoverRadius: 'pointHoverRadius', + pointStyle: 'pointStyle', + radius: 'pointRadius', + rotation: 'pointRotation' + }, + + /** + * @private + */ + _getIndexScaleId: function() { + return this.chart.scale.id; + }, + + /** + * @private + */ + _getValueScaleId: function() { + return this.chart.scale.id; + }, + + update: function(reset) { + var me = this; + var meta = me.getMeta(); + var line = meta.dataset; + var points = meta.data || []; + var scale = me.chart.scale; + var config = me._config; + var i, ilen; + + // Compatibility: If the properties are defined with only the old name, use those values + if (config.tension !== undefined && config.lineTension === undefined) { + config.lineTension = config.tension; + } + + // Utility + line._scale = scale; + line._datasetIndex = me.index; + // Data + line._children = points; + line._loop = true; + // Model + line._model = me._resolveDatasetElementOptions(line); + + line.pivot(); + + // Update Points + for (i = 0, ilen = points.length; i < ilen; ++i) { + me.updateElement(points[i], i, reset); + } + + // Update bezier control points + me.updateBezierControlPoints(); + + // Now pivot the point for animation + for (i = 0, ilen = points.length; i < ilen; ++i) { + points[i].pivot(); + } + }, + + updateElement: function(point, index, reset) { + var me = this; + var custom = point.custom || {}; + var dataset = me.getDataset(); + var scale = me.chart.scale; + var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]); + var options = me._resolveDataElementOptions(point, index); + var lineModel = me.getMeta().dataset._model; + var x = reset ? scale.xCenter : pointPosition.x; + var y = reset ? scale.yCenter : pointPosition.y; + + // Utility + point._scale = scale; + point._options = options; + point._datasetIndex = me.index; + point._index = index; + + // Desired view properties + point._model = { + x: x, // value not used in dataset scale, but we want a consistent API between scales + y: y, + skip: custom.skip || isNaN(x) || isNaN(y), + // Appearance + radius: options.radius, + pointStyle: options.pointStyle, + rotation: options.rotation, + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + tension: valueOrDefault$7(custom.tension, lineModel ? lineModel.tension : 0), + + // Tooltip + hitRadius: options.hitRadius + }; + }, + + /** + * @private + */ + _resolveDatasetElementOptions: function() { + var me = this; + var config = me._config; + var options = me.chart.options; + var values = core_datasetController.prototype._resolveDatasetElementOptions.apply(me, arguments); + + values.spanGaps = valueOrDefault$7(config.spanGaps, options.spanGaps); + values.tension = valueOrDefault$7(config.lineTension, options.elements.line.tension); + + return values; + }, + + updateBezierControlPoints: function() { + var me = this; + var meta = me.getMeta(); + var area = me.chart.chartArea; + var points = meta.data || []; + var i, ilen, model, controlPoints; + + // Only consider points that are drawn in case the spanGaps option is used + if (meta.dataset._model.spanGaps) { + points = points.filter(function(pt) { + return !pt._model.skip; + }); + } + + function capControlPoint(pt, min, max) { + return Math.max(Math.min(pt, max), min); + } + + for (i = 0, ilen = points.length; i < ilen; ++i) { + model = points[i]._model; + controlPoints = helpers$1.splineCurve( + helpers$1.previousItem(points, i, true)._model, + model, + helpers$1.nextItem(points, i, true)._model, + model.tension + ); + + // Prevent the bezier going outside of the bounds of the graph + model.controlPointPreviousX = capControlPoint(controlPoints.previous.x, area.left, area.right); + model.controlPointPreviousY = capControlPoint(controlPoints.previous.y, area.top, area.bottom); + model.controlPointNextX = capControlPoint(controlPoints.next.x, area.left, area.right); + model.controlPointNextY = capControlPoint(controlPoints.next.y, area.top, area.bottom); + } + }, + + setHoverStyle: function(point) { + var model = point._model; + var options = point._options; + var getHoverColor = helpers$1.getHoverColor; + + point.$previousStyle = { + backgroundColor: model.backgroundColor, + borderColor: model.borderColor, + borderWidth: model.borderWidth, + radius: model.radius + }; + + model.backgroundColor = valueOrDefault$7(options.hoverBackgroundColor, getHoverColor(options.backgroundColor)); + model.borderColor = valueOrDefault$7(options.hoverBorderColor, getHoverColor(options.borderColor)); + model.borderWidth = valueOrDefault$7(options.hoverBorderWidth, options.borderWidth); + model.radius = valueOrDefault$7(options.hoverRadius, options.radius); + } +}); + +core_defaults._set('scatter', { + hover: { + mode: 'single' + }, + + scales: { + xAxes: [{ + id: 'x-axis-1', // need an ID so datasets can reference the scale + type: 'linear', // scatter should not use a category axis + position: 'bottom' + }], + yAxes: [{ + id: 'y-axis-1', + type: 'linear', + position: 'left' + }] + }, + + tooltips: { + callbacks: { + title: function() { + return ''; // doesn't make sense for scatter since data are formatted as a point + }, + label: function(item) { + return '(' + item.xLabel + ', ' + item.yLabel + ')'; + } + } + } +}); + +core_defaults._set('global', { + datasets: { + scatter: { + showLine: false + } + } +}); + +// Scatter charts use line controllers +var controller_scatter = controller_line; + +// NOTE export a map in which the key represents the controller type, not +// the class, and so must be CamelCase in order to be correctly retrieved +// by the controller in core.controller.js (`controllers[meta.type]`). + +var controllers = { + bar: controller_bar, + bubble: controller_bubble, + doughnut: controller_doughnut, + horizontalBar: controller_horizontalBar, + line: controller_line, + polarArea: controller_polarArea, + pie: controller_pie, + radar: controller_radar, + scatter: controller_scatter +}; + +/** + * Helper function to get relative position for an event + * @param {Event|IEvent} event - The event to get the position for + * @param {Chart} chart - The chart + * @returns {object} the event position + */ +function getRelativePosition(e, chart) { + if (e.native) { + return { + x: e.x, + y: e.y + }; + } + + return helpers$1.getRelativePosition(e, chart); +} + +/** + * Helper function to traverse all of the visible elements in the chart + * @param {Chart} chart - the chart + * @param {function} handler - the callback to execute for each visible item + */ +function parseVisibleItems(chart, handler) { + var metasets = chart._getSortedVisibleDatasetMetas(); + var metadata, i, j, ilen, jlen, element; + + for (i = 0, ilen = metasets.length; i < ilen; ++i) { + metadata = metasets[i].data; + for (j = 0, jlen = metadata.length; j < jlen; ++j) { + element = metadata[j]; + if (!element._view.skip) { + handler(element); + } + } + } +} + +/** + * Helper function to get the items that intersect the event position + * @param {ChartElement[]} items - elements to filter + * @param {object} position - the point to be nearest to + * @return {ChartElement[]} the nearest items + */ +function getIntersectItems(chart, position) { + var elements = []; + + parseVisibleItems(chart, function(element) { + if (element.inRange(position.x, position.y)) { + elements.push(element); + } + }); + + return elements; +} + +/** + * Helper function to get the items nearest to the event position considering all visible items in teh chart + * @param {Chart} chart - the chart to look at elements from + * @param {object} position - the point to be nearest to + * @param {boolean} intersect - if true, only consider items that intersect the position + * @param {function} distanceMetric - function to provide the distance between points + * @return {ChartElement[]} the nearest items + */ +function getNearestItems(chart, position, intersect, distanceMetric) { + var minDistance = Number.POSITIVE_INFINITY; + var nearestItems = []; + + parseVisibleItems(chart, function(element) { + if (intersect && !element.inRange(position.x, position.y)) { + return; + } + + var center = element.getCenterPoint(); + var distance = distanceMetric(position, center); + if (distance < minDistance) { + nearestItems = [element]; + minDistance = distance; + } else if (distance === minDistance) { + // Can have multiple items at the same distance in which case we sort by size + nearestItems.push(element); + } + }); + + return nearestItems; +} + +/** + * Get a distance metric function for two points based on the + * axis mode setting + * @param {string} axis - the axis mode. x|y|xy + */ +function getDistanceMetricForAxis(axis) { + var useX = axis.indexOf('x') !== -1; + var useY = axis.indexOf('y') !== -1; + + return function(pt1, pt2) { + var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0; + var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0; + return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); + }; +} + +function indexMode(chart, e, options) { + var position = getRelativePosition(e, chart); + // Default axis for index mode is 'x' to match old behaviour + options.axis = options.axis || 'x'; + var distanceMetric = getDistanceMetricForAxis(options.axis); + var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric); + var elements = []; + + if (!items.length) { + return []; + } + + chart._getSortedVisibleDatasetMetas().forEach(function(meta) { + var element = meta.data[items[0]._index]; + + // don't count items that are skipped (null data) + if (element && !element._view.skip) { + elements.push(element); + } + }); + + return elements; +} + +/** + * @interface IInteractionOptions + */ +/** + * If true, only consider items that intersect the point + * @name IInterfaceOptions#boolean + * @type Boolean + */ + +/** + * Contains interaction related functions + * @namespace Chart.Interaction + */ +var core_interaction = { + // Helper function for different modes + modes: { + single: function(chart, e) { + var position = getRelativePosition(e, chart); + var elements = []; + + parseVisibleItems(chart, function(element) { + if (element.inRange(position.x, position.y)) { + elements.push(element); + return elements; + } + }); + + return elements.slice(0, 1); + }, + + /** + * @function Chart.Interaction.modes.label + * @deprecated since version 2.4.0 + * @todo remove at version 3 + * @private + */ + label: indexMode, + + /** + * Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something + * If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item + * @function Chart.Interaction.modes.index + * @since v2.4.0 + * @param {Chart} chart - the chart we are returning items from + * @param {Event} e - the event we are find things at + * @param {IInteractionOptions} options - options to use during interaction + * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned + */ + index: indexMode, + + /** + * Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something + * If the options.intersect is false, we find the nearest item and return the items in that dataset + * @function Chart.Interaction.modes.dataset + * @param {Chart} chart - the chart we are returning items from + * @param {Event} e - the event we are find things at + * @param {IInteractionOptions} options - options to use during interaction + * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned + */ + dataset: function(chart, e, options) { + var position = getRelativePosition(e, chart); + options.axis = options.axis || 'xy'; + var distanceMetric = getDistanceMetricForAxis(options.axis); + var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric); + + if (items.length > 0) { + items = chart.getDatasetMeta(items[0]._datasetIndex).data; + } + + return items; + }, + + /** + * @function Chart.Interaction.modes.x-axis + * @deprecated since version 2.4.0. Use index mode and intersect == true + * @todo remove at version 3 + * @private + */ + 'x-axis': function(chart, e) { + return indexMode(chart, e, {intersect: false}); + }, + + /** + * Point mode returns all elements that hit test based on the event position + * of the event + * @function Chart.Interaction.modes.intersect + * @param {Chart} chart - the chart we are returning items from + * @param {Event} e - the event we are find things at + * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned + */ + point: function(chart, e) { + var position = getRelativePosition(e, chart); + return getIntersectItems(chart, position); + }, + + /** + * nearest mode returns the element closest to the point + * @function Chart.Interaction.modes.intersect + * @param {Chart} chart - the chart we are returning items from + * @param {Event} e - the event we are find things at + * @param {IInteractionOptions} options - options to use + * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned + */ + nearest: function(chart, e, options) { + var position = getRelativePosition(e, chart); + options.axis = options.axis || 'xy'; + var distanceMetric = getDistanceMetricForAxis(options.axis); + return getNearestItems(chart, position, options.intersect, distanceMetric); + }, + + /** + * x mode returns the elements that hit-test at the current x coordinate + * @function Chart.Interaction.modes.x + * @param {Chart} chart - the chart we are returning items from + * @param {Event} e - the event we are find things at + * @param {IInteractionOptions} options - options to use + * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned + */ + x: function(chart, e, options) { + var position = getRelativePosition(e, chart); + var items = []; + var intersectsItem = false; + + parseVisibleItems(chart, function(element) { + if (element.inXRange(position.x)) { + items.push(element); + } + + if (element.inRange(position.x, position.y)) { + intersectsItem = true; + } + }); + + // If we want to trigger on an intersect and we don't have any items + // that intersect the position, return nothing + if (options.intersect && !intersectsItem) { + items = []; + } + return items; + }, + + /** + * y mode returns the elements that hit-test at the current y coordinate + * @function Chart.Interaction.modes.y + * @param {Chart} chart - the chart we are returning items from + * @param {Event} e - the event we are find things at + * @param {IInteractionOptions} options - options to use + * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned + */ + y: function(chart, e, options) { + var position = getRelativePosition(e, chart); + var items = []; + var intersectsItem = false; + + parseVisibleItems(chart, function(element) { + if (element.inYRange(position.y)) { + items.push(element); + } + + if (element.inRange(position.x, position.y)) { + intersectsItem = true; + } + }); + + // If we want to trigger on an intersect and we don't have any items + // that intersect the position, return nothing + if (options.intersect && !intersectsItem) { + items = []; + } + return items; + } + } +}; + +var extend = helpers$1.extend; + +function filterByPosition(array, position) { + return helpers$1.where(array, function(v) { + return v.pos === position; + }); +} + +function sortByWeight(array, reverse) { + return array.sort(function(a, b) { + var v0 = reverse ? b : a; + var v1 = reverse ? a : b; + return v0.weight === v1.weight ? + v0.index - v1.index : + v0.weight - v1.weight; + }); +} + +function wrapBoxes(boxes) { + var layoutBoxes = []; + var i, ilen, box; + + for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) { + box = boxes[i]; + layoutBoxes.push({ + index: i, + box: box, + pos: box.position, + horizontal: box.isHorizontal(), + weight: box.weight + }); + } + return layoutBoxes; +} + +function setLayoutDims(layouts, params) { + var i, ilen, layout; + for (i = 0, ilen = layouts.length; i < ilen; ++i) { + layout = layouts[i]; + // store width used instead of chartArea.w in fitBoxes + layout.width = layout.horizontal + ? layout.box.fullWidth && params.availableWidth + : params.vBoxMaxWidth; + // store height used instead of chartArea.h in fitBoxes + layout.height = layout.horizontal && params.hBoxMaxHeight; + } +} + +function buildLayoutBoxes(boxes) { + var layoutBoxes = wrapBoxes(boxes); + var left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true); + var right = sortByWeight(filterByPosition(layoutBoxes, 'right')); + var top = sortByWeight(filterByPosition(layoutBoxes, 'top'), true); + var bottom = sortByWeight(filterByPosition(layoutBoxes, 'bottom')); + + return { + leftAndTop: left.concat(top), + rightAndBottom: right.concat(bottom), + chartArea: filterByPosition(layoutBoxes, 'chartArea'), + vertical: left.concat(right), + horizontal: top.concat(bottom) + }; +} + +function getCombinedMax(maxPadding, chartArea, a, b) { + return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]); +} + +function updateDims(chartArea, params, layout) { + var box = layout.box; + var maxPadding = chartArea.maxPadding; + var newWidth, newHeight; + + if (layout.size) { + // this layout was already counted for, lets first reduce old size + chartArea[layout.pos] -= layout.size; + } + layout.size = layout.horizontal ? box.height : box.width; + chartArea[layout.pos] += layout.size; + + if (box.getPadding) { + var boxPadding = box.getPadding(); + maxPadding.top = Math.max(maxPadding.top, boxPadding.top); + maxPadding.left = Math.max(maxPadding.left, boxPadding.left); + maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom); + maxPadding.right = Math.max(maxPadding.right, boxPadding.right); + } + + newWidth = params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'); + newHeight = params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'); + + if (newWidth !== chartArea.w || newHeight !== chartArea.h) { + chartArea.w = newWidth; + chartArea.h = newHeight; + + // return true if chart area changed in layout's direction + return layout.horizontal ? newWidth !== chartArea.w : newHeight !== chartArea.h; + } +} + +function handleMaxPadding(chartArea) { + var maxPadding = chartArea.maxPadding; + + function updatePos(pos) { + var change = Math.max(maxPadding[pos] - chartArea[pos], 0); + chartArea[pos] += change; + return change; + } + chartArea.y += updatePos('top'); + chartArea.x += updatePos('left'); + updatePos('right'); + updatePos('bottom'); +} + +function getMargins(horizontal, chartArea) { + var maxPadding = chartArea.maxPadding; + + function marginForPositions(positions) { + var margin = {left: 0, top: 0, right: 0, bottom: 0}; + positions.forEach(function(pos) { + margin[pos] = Math.max(chartArea[pos], maxPadding[pos]); + }); + return margin; + } + + return horizontal + ? marginForPositions(['left', 'right']) + : marginForPositions(['top', 'bottom']); +} + +function fitBoxes(boxes, chartArea, params) { + var refitBoxes = []; + var i, ilen, layout, box, refit, changed; + + for (i = 0, ilen = boxes.length; i < ilen; ++i) { + layout = boxes[i]; + box = layout.box; + + box.update( + layout.width || chartArea.w, + layout.height || chartArea.h, + getMargins(layout.horizontal, chartArea) + ); + if (updateDims(chartArea, params, layout)) { + changed = true; + if (refitBoxes.length) { + // Dimensions changed and there were non full width boxes before this + // -> we have to refit those + refit = true; + } + } + if (!box.fullWidth) { // fullWidth boxes don't need to be re-fitted in any case + refitBoxes.push(layout); + } + } + + return refit ? fitBoxes(refitBoxes, chartArea, params) || changed : changed; +} + +function placeBoxes(boxes, chartArea, params) { + var userPadding = params.padding; + var x = chartArea.x; + var y = chartArea.y; + var i, ilen, layout, box; + + for (i = 0, ilen = boxes.length; i < ilen; ++i) { + layout = boxes[i]; + box = layout.box; + if (layout.horizontal) { + box.left = box.fullWidth ? userPadding.left : chartArea.left; + box.right = box.fullWidth ? params.outerWidth - userPadding.right : chartArea.left + chartArea.w; + box.top = y; + box.bottom = y + box.height; + box.width = box.right - box.left; + y = box.bottom; + } else { + box.left = x; + box.right = x + box.width; + box.top = chartArea.top; + box.bottom = chartArea.top + chartArea.h; + box.height = box.bottom - box.top; + x = box.right; + } + } + + chartArea.x = x; + chartArea.y = y; +} + +core_defaults._set('global', { + layout: { + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + } + } +}); + +/** + * @interface ILayoutItem + * @prop {string} position - The position of the item in the chart layout. Possible values are + * 'left', 'top', 'right', 'bottom', and 'chartArea' + * @prop {number} weight - The weight used to sort the item. Higher weights are further away from the chart area + * @prop {boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down + * @prop {function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom) + * @prop {function} update - Takes two parameters: width and height. Returns size of item + * @prop {function} getPadding - Returns an object with padding on the edges + * @prop {number} width - Width of item. Must be valid after update() + * @prop {number} height - Height of item. Must be valid after update() + * @prop {number} left - Left edge of the item. Set by layout system and cannot be used in update + * @prop {number} top - Top edge of the item. Set by layout system and cannot be used in update + * @prop {number} right - Right edge of the item. Set by layout system and cannot be used in update + * @prop {number} bottom - Bottom edge of the item. Set by layout system and cannot be used in update + */ + +// The layout service is very self explanatory. It's responsible for the layout within a chart. +// Scales, Legends and Plugins all rely on the layout service and can easily register to be placed anywhere they need +// It is this service's responsibility of carrying out that layout. +var core_layouts = { + defaults: {}, + + /** + * Register a box to a chart. + * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title. + * @param {Chart} chart - the chart to use + * @param {ILayoutItem} item - the item to add to be layed out + */ + addBox: function(chart, item) { + if (!chart.boxes) { + chart.boxes = []; + } + + // initialize item with default values + item.fullWidth = item.fullWidth || false; + item.position = item.position || 'top'; + item.weight = item.weight || 0; + item._layers = item._layers || function() { + return [{ + z: 0, + draw: function() { + item.draw.apply(item, arguments); + } + }]; + }; + + chart.boxes.push(item); + }, + + /** + * Remove a layoutItem from a chart + * @param {Chart} chart - the chart to remove the box from + * @param {ILayoutItem} layoutItem - the item to remove from the layout + */ + removeBox: function(chart, layoutItem) { + var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; + if (index !== -1) { + chart.boxes.splice(index, 1); + } + }, + + /** + * Sets (or updates) options on the given `item`. + * @param {Chart} chart - the chart in which the item lives (or will be added to) + * @param {ILayoutItem} item - the item to configure with the given options + * @param {object} options - the new item options. + */ + configure: function(chart, item, options) { + var props = ['fullWidth', 'position', 'weight']; + var ilen = props.length; + var i = 0; + var prop; + + for (; i < ilen; ++i) { + prop = props[i]; + if (options.hasOwnProperty(prop)) { + item[prop] = options[prop]; + } + } + }, + + /** + * Fits boxes of the given chart into the given size by having each box measure itself + * then running a fitting algorithm + * @param {Chart} chart - the chart + * @param {number} width - the width to fit into + * @param {number} height - the height to fit into + */ + update: function(chart, width, height) { + if (!chart) { + return; + } + + var layoutOptions = chart.options.layout || {}; + var padding = helpers$1.options.toPadding(layoutOptions.padding); + + var availableWidth = width - padding.width; + var availableHeight = height - padding.height; + var boxes = buildLayoutBoxes(chart.boxes); + var verticalBoxes = boxes.vertical; + var horizontalBoxes = boxes.horizontal; + + // Essentially we now have any number of boxes on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // There are also 4 quadrant-like locations (left to right instead of clockwise) reserved for chart overlays + // These locations are single-box locations only, when trying to register a chartArea location that is already taken, + // an error will be thrown. + // + // |----------------------------------------------------| + // | T1 (Full Width) | + // |----------------------------------------------------| + // | | | T2 | | + // | |----|-------------------------------------|----| + // | | | C1 | | C2 | | + // | | |----| |----| | + // | | | | | + // | L1 | L2 | ChartArea (C0) | R1 | + // | | | | | + // | | |----| |----| | + // | | | C3 | | C4 | | + // | |----|-------------------------------------|----| + // | | | B1 | | + // |----------------------------------------------------| + // | B2 (Full Width) | + // |----------------------------------------------------| + // + + var params = Object.freeze({ + outerWidth: width, + outerHeight: height, + padding: padding, + availableWidth: availableWidth, + vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length, + hBoxMaxHeight: availableHeight / 2 + }); + var chartArea = extend({ + maxPadding: extend({}, padding), + w: availableWidth, + h: availableHeight, + x: padding.left, + y: padding.top + }, padding); + + setLayoutDims(verticalBoxes.concat(horizontalBoxes), params); + + // First fit vertical boxes + fitBoxes(verticalBoxes, chartArea, params); + + // Then fit horizontal boxes + if (fitBoxes(horizontalBoxes, chartArea, params)) { + // if the area changed, re-fit vertical boxes + fitBoxes(verticalBoxes, chartArea, params); + } + + handleMaxPadding(chartArea); + + // Finally place the boxes to correct coordinates + placeBoxes(boxes.leftAndTop, chartArea, params); + + // Move to opposite side of chart + chartArea.x += chartArea.w; + chartArea.y += chartArea.h; + + placeBoxes(boxes.rightAndBottom, chartArea, params); + + chart.chartArea = { + left: chartArea.left, + top: chartArea.top, + right: chartArea.left + chartArea.w, + bottom: chartArea.top + chartArea.h + }; + + // Finally update boxes in chartArea (radial scale for example) + helpers$1.each(boxes.chartArea, function(layout) { + var box = layout.box; + extend(box, chart.chartArea); + box.update(chartArea.w, chartArea.h); + }); + } +}; + +/** + * Platform fallback implementation (minimal). + * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939 + */ + +var platform_basic = { + acquireContext: function(item) { + if (item && item.canvas) { + // Support for any object associated to a canvas (including a context2d) + item = item.canvas; + } + + return item && item.getContext('2d') || null; + } +}; + +var platform_dom = "/*\n * DOM element rendering detection\n * https://davidwalsh.name/detect-node-insertion\n */\n@keyframes chartjs-render-animation {\n\tfrom { opacity: 0.99; }\n\tto { opacity: 1; }\n}\n\n.chartjs-render-monitor {\n\tanimation: chartjs-render-animation 0.001s;\n}\n\n/*\n * DOM element resizing detection\n * https://github.com/marcj/css-element-queries\n */\n.chartjs-size-monitor,\n.chartjs-size-monitor-expand,\n.chartjs-size-monitor-shrink {\n\tposition: absolute;\n\tdirection: ltr;\n\tleft: 0;\n\ttop: 0;\n\tright: 0;\n\tbottom: 0;\n\toverflow: hidden;\n\tpointer-events: none;\n\tvisibility: hidden;\n\tz-index: -1;\n}\n\n.chartjs-size-monitor-expand > div {\n\tposition: absolute;\n\twidth: 1000000px;\n\theight: 1000000px;\n\tleft: 0;\n\ttop: 0;\n}\n\n.chartjs-size-monitor-shrink > div {\n\tposition: absolute;\n\twidth: 200%;\n\theight: 200%;\n\tleft: 0;\n\ttop: 0;\n}\n"; + +var platform_dom$1 = /*#__PURE__*/Object.freeze({ +__proto__: null, +'default': platform_dom +}); + +var stylesheet = getCjsExportFromNamespace(platform_dom$1); + +var EXPANDO_KEY = '$chartjs'; +var CSS_PREFIX = 'chartjs-'; +var CSS_SIZE_MONITOR = CSS_PREFIX + 'size-monitor'; +var CSS_RENDER_MONITOR = CSS_PREFIX + 'render-monitor'; +var CSS_RENDER_ANIMATION = CSS_PREFIX + 'render-animation'; +var ANIMATION_START_EVENTS = ['animationstart', 'webkitAnimationStart']; + +/** + * DOM event types -> Chart.js event types. + * Note: only events with different types are mapped. + * @see https://developer.mozilla.org/en-US/docs/Web/Events + */ +var EVENT_TYPES = { + touchstart: 'mousedown', + touchmove: 'mousemove', + touchend: 'mouseup', + pointerenter: 'mouseenter', + pointerdown: 'mousedown', + pointermove: 'mousemove', + pointerup: 'mouseup', + pointerleave: 'mouseout', + pointerout: 'mouseout' +}; + +/** + * The "used" size is the final value of a dimension property after all calculations have + * been performed. This method uses the computed style of `element` but returns undefined + * if the computed style is not expressed in pixels. That can happen in some cases where + * `element` has a size relative to its parent and this last one is not yet displayed, + * for example because of `display: none` on a parent node. + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value + * @returns {number} Size in pixels or undefined if unknown. + */ +function readUsedSize(element, property) { + var value = helpers$1.getStyle(element, property); + var matches = value && value.match(/^(\d+)(\.\d+)?px$/); + return matches ? Number(matches[1]) : undefined; +} + +/** + * Initializes the canvas style and render size without modifying the canvas display size, + * since responsiveness is handled by the controller.resize() method. The config is used + * to determine the aspect ratio to apply in case no explicit height has been specified. + */ +function initCanvas(canvas, config) { + var style = canvas.style; + + // NOTE(SB) canvas.getAttribute('width') !== canvas.width: in the first case it + // returns null or '' if no explicit value has been set to the canvas attribute. + var renderHeight = canvas.getAttribute('height'); + var renderWidth = canvas.getAttribute('width'); + + // Chart.js modifies some canvas values that we want to restore on destroy + canvas[EXPANDO_KEY] = { + initial: { + height: renderHeight, + width: renderWidth, + style: { + display: style.display, + height: style.height, + width: style.width + } + } + }; + + // Force canvas to display as block to avoid extra space caused by inline + // elements, which would interfere with the responsive resize process. + // https://github.com/chartjs/Chart.js/issues/2538 + style.display = style.display || 'block'; + + if (renderWidth === null || renderWidth === '') { + var displayWidth = readUsedSize(canvas, 'width'); + if (displayWidth !== undefined) { + canvas.width = displayWidth; + } + } + + if (renderHeight === null || renderHeight === '') { + if (canvas.style.height === '') { + // If no explicit render height and style height, let's apply the aspect ratio, + // which one can be specified by the user but also by charts as default option + // (i.e. options.aspectRatio). If not specified, use canvas aspect ratio of 2. + canvas.height = canvas.width / (config.options.aspectRatio || 2); + } else { + var displayHeight = readUsedSize(canvas, 'height'); + if (displayWidth !== undefined) { + canvas.height = displayHeight; + } + } + } + + return canvas; +} + +/** + * Detects support for options object argument in addEventListener. + * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support + * @private + */ +var supportsEventListenerOptions = (function() { + var supports = false; + try { + var options = Object.defineProperty({}, 'passive', { + // eslint-disable-next-line getter-return + get: function() { + supports = true; + } + }); + window.addEventListener('e', null, options); + } catch (e) { + // continue regardless of error + } + return supports; +}()); + +// Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events. +// https://github.com/chartjs/Chart.js/issues/4287 +var eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false; + +function addListener(node, type, listener) { + node.addEventListener(type, listener, eventListenerOptions); +} + +function removeListener(node, type, listener) { + node.removeEventListener(type, listener, eventListenerOptions); +} + +function createEvent(type, chart, x, y, nativeEvent) { + return { + type: type, + chart: chart, + native: nativeEvent || null, + x: x !== undefined ? x : null, + y: y !== undefined ? y : null, + }; +} + +function fromNativeEvent(event, chart) { + var type = EVENT_TYPES[event.type] || event.type; + var pos = helpers$1.getRelativePosition(event, chart); + return createEvent(type, chart, pos.x, pos.y, event); +} + +function throttled(fn, thisArg) { + var ticking = false; + var args = []; + + return function() { + args = Array.prototype.slice.call(arguments); + thisArg = thisArg || this; + + if (!ticking) { + ticking = true; + helpers$1.requestAnimFrame.call(window, function() { + ticking = false; + fn.apply(thisArg, args); + }); + } + }; +} + +function createDiv(cls) { + var el = document.createElement('div'); + el.className = cls || ''; + return el; +} + +// Implementation based on https://github.com/marcj/css-element-queries +function createResizer(handler) { + var maxSize = 1000000; + + // NOTE(SB) Don't use innerHTML because it could be considered unsafe. + // https://github.com/chartjs/Chart.js/issues/5902 + var resizer = createDiv(CSS_SIZE_MONITOR); + var expand = createDiv(CSS_SIZE_MONITOR + '-expand'); + var shrink = createDiv(CSS_SIZE_MONITOR + '-shrink'); + + expand.appendChild(createDiv()); + shrink.appendChild(createDiv()); + + resizer.appendChild(expand); + resizer.appendChild(shrink); + resizer._reset = function() { + expand.scrollLeft = maxSize; + expand.scrollTop = maxSize; + shrink.scrollLeft = maxSize; + shrink.scrollTop = maxSize; + }; + + var onScroll = function() { + resizer._reset(); + handler(); + }; + + addListener(expand, 'scroll', onScroll.bind(expand, 'expand')); + addListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink')); + + return resizer; +} + +// https://davidwalsh.name/detect-node-insertion +function watchForRender(node, handler) { + var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {}); + var proxy = expando.renderProxy = function(e) { + if (e.animationName === CSS_RENDER_ANIMATION) { + handler(); + } + }; + + helpers$1.each(ANIMATION_START_EVENTS, function(type) { + addListener(node, type, proxy); + }); + + // #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR class + // is removed then added back immediately (same animation frame?). Accessing the + // `offsetParent` property will force a reflow and re-evaluate the CSS animation. + // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics + // https://github.com/chartjs/Chart.js/issues/4737 + expando.reflow = !!node.offsetParent; + + node.classList.add(CSS_RENDER_MONITOR); +} + +function unwatchForRender(node) { + var expando = node[EXPANDO_KEY] || {}; + var proxy = expando.renderProxy; + + if (proxy) { + helpers$1.each(ANIMATION_START_EVENTS, function(type) { + removeListener(node, type, proxy); + }); + + delete expando.renderProxy; + } + + node.classList.remove(CSS_RENDER_MONITOR); +} + +function addResizeListener(node, listener, chart) { + var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {}); + + // Let's keep track of this added resizer and thus avoid DOM query when removing it. + var resizer = expando.resizer = createResizer(throttled(function() { + if (expando.resizer) { + var container = chart.options.maintainAspectRatio && node.parentNode; + var w = container ? container.clientWidth : 0; + listener(createEvent('resize', chart)); + if (container && container.clientWidth < w && chart.canvas) { + // If the container size shrank during chart resize, let's assume + // scrollbar appeared. So we resize again with the scrollbar visible - + // effectively making chart smaller and the scrollbar hidden again. + // Because we are inside `throttled`, and currently `ticking`, scroll + // events are ignored during this whole 2 resize process. + // If we assumed wrong and something else happened, we are resizing + // twice in a frame (potential performance issue) + listener(createEvent('resize', chart)); + } + } + })); + + // The resizer needs to be attached to the node parent, so we first need to be + // sure that `node` is attached to the DOM before injecting the resizer element. + watchForRender(node, function() { + if (expando.resizer) { + var container = node.parentNode; + if (container && container !== resizer.parentNode) { + container.insertBefore(resizer, container.firstChild); + } + + // The container size might have changed, let's reset the resizer state. + resizer._reset(); + } + }); +} + +function removeResizeListener(node) { + var expando = node[EXPANDO_KEY] || {}; + var resizer = expando.resizer; + + delete expando.resizer; + unwatchForRender(node); + + if (resizer && resizer.parentNode) { + resizer.parentNode.removeChild(resizer); + } +} + +/** + * Injects CSS styles inline if the styles are not already present. + * @param {HTMLDocument|ShadowRoot} rootNode - the node to contain the '; -$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); +$arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); // Search modules dirs $modulesdir = dolGetModulesDirs(); @@ -76,30 +76,30 @@ $modules = array(); $orders = array(); $categ = array(); $dirmod = array(); -$i = 0; // is a sequencer of modules found -$j = 0; // j is module number. Automatically affected if module number not defined. -$modNameLoaded=array(); +$i = 0; // is a sequencer of modules found +$j = 0; // j is module number. Automatically affected if module number not defined. +$modNameLoaded = array(); foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)"); - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { - if (! empty($modNameLoaded[$modName])) + if (!empty($modNameLoaded[$modName])) { - $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; setEventMessages($mesg, null, 'warnings'); dol_syslog($mesg, LOG_ERR); continue; @@ -107,43 +107,43 @@ foreach ($modulesdir as $dir) try { - $res=include_once $dir.$file; + $res = include_once $dir.$file; if (class_exists($modName)) { try { $objMod = new $modName($db); - $modNameLoaded[$modName]=$dir; + $modNameLoaded[$modName] = $dir; - if (! $objMod->numero > 0 && $modName != 'modUser') + if (!$objMod->numero > 0 && $modName != 'modUser') { dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); } $j = $objMod->numero; - $modulequalified=1; + $modulequalified = 1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0; - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0; - if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0; + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; + if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; // We discard modules according to property disabled //if (! empty($objMod->hidden)) $modulequalified=0; if ($modulequalified > 0) { - $publisher=dol_escape_htmltag($objMod->getPublisher()); - $external=($objMod->isCoreOrExternalModule() == 'external'); + $publisher = dol_escape_htmltag($objMod->getPublisher()); + $external = ($objMod->isCoreOrExternalModule() == 'external'); if ($external) { if ($publisher) { - $arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher; + $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; } else { - $arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers"); + $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); } } ksort($arrayofnatures); @@ -153,37 +153,37 @@ foreach ($modulesdir as $dir) if ($modulequalified > 0) { $modules[$i] = $objMod; - $filename[$i]= $modName; + $filename[$i] = $modName; // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { - if (!is_array($familyinfo)) $familyinfo=array(); + if (!is_array($familyinfo)) $familyinfo = array(); $familyinfo = array_merge($familyinfo, $objMod->familyinfo); $familykey = key($objMod->familyinfo); } else { $familykey = $objMod->family; } - $moduleposition = ($objMod->module_position?$objMod->module_position:'50'); + $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) { - $moduleposition = '80'; // External modules at end by default + $moduleposition = '80'; // External modules at end by default } - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number - $dirmod[$i] = $dir; + $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number + $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories - else $categ[$specialstring]=1; + if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; + if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories + else $categ[$specialstring] = 1; $j++; $i++; } else dol_syslog("Module ".get_class($objMod)." not qualified"); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } @@ -193,7 +193,7 @@ foreach ($modulesdir as $dir) print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } @@ -215,8 +215,8 @@ asort($orders); unset($objMod); -$i=0; -foreach($orders as $tmpkey => $tmpvalue) +$i = 0; +foreach ($orders as $tmpkey => $tmpvalue) { $tmpMod = $modules[$tmpkey]; if ($tmpMod->numero == $id) @@ -230,54 +230,54 @@ foreach($orders as $tmpkey => $tmpvalue) $i++; } $value = $orders[$key]; -$tab=explode('_', $value); -$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3]; +$tab = explode('_', $value); +$familyposition = $tab[0]; $familykey = $tab[1]; $module_position = $tab[2]; $numero = $tab[3]; $head = modulehelp_prepare_head($objMod); // Check filters -$modulename=$objMod->getName(); -$moduledesc=$objMod->getDesc(); -$moduleauthor=$objMod->getPublisher(); -$moduledir=strtolower(preg_replace('/^mod/i', '', get_class($objMod))); +$modulename = $objMod->getName(); +$moduledesc = $objMod->getDesc(); +$moduleauthor = $objMod->getPublisher(); +$moduledir = strtolower(preg_replace('/^mod/i', '', get_class($objMod))); $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); $text = ''.$langs->trans("LastActivationDate").': '; -if (! empty($conf->global->$const_name)) $text.=dol_print_date($objMod->getLastActivationDate(), 'dayhour'); -else $text.=$langs->trans("Disabled"); +if (!empty($conf->global->$const_name)) $text .= dol_print_date($objMod->getLastActivationDate(), 'dayhour'); +else $text .= $langs->trans("Disabled"); $tmp = $objMod->getLastActivationInfo(); $authorid = $tmp['authorid']; if ($authorid > 0) { $tmpuser = new User($db); $tmpuser->fetch($authorid); - $text.='
'.$langs->trans("LastActivationAuthor").': '; - $text.= $tmpuser->getNomUrl(1); + $text .= '
'.$langs->trans("LastActivationAuthor").': '; + $text .= $tmpuser->getNomUrl(1); } $ip = $tmp['ip']; if ($ip) { - $text.='
'.$langs->trans("LastActivationIP").': '; - $text.= $ip; + $text .= '
'.$langs->trans("LastActivationIP").': '; + $text .= $ip; } $moreinfo = $text; -$title = ($modulename?$modulename:$moduledesc); +$title = ($modulename ? $modulename : $moduledesc); print '
'; $picto = 'object_'.$objMod->picto; -print load_fiche_titre(($modulename?$modulename:$moduledesc), $moreinfo, $picto); +print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto); print '
'; dol_fiche_head($head, $mode, '', -1); -if (! $modulename) +if (!$modulename) { dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING); } @@ -285,7 +285,7 @@ if (! $modulename) // Load all lang files of module if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { - foreach($objMod->langfiles as $domain) + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } @@ -295,197 +295,197 @@ if (isset($objMod->langfiles) && is_array($objMod->langfiles)) // Version (with picto warning or not) -$version=$objMod->getVersion(0); -$versiontrans=''; -if (preg_match('/development/i', $version)) $versiontrans.=img_warning($langs->trans("Development"), 'style="float: left"'); -if (preg_match('/experimental/i', $version)) $versiontrans.=img_warning($langs->trans("Experimental"), 'style="float: left"'); -if (preg_match('/deprecated/i', $version)) $versiontrans.=img_warning($langs->trans("Deprecated"), 'style="float: left"'); -$versiontrans.=$objMod->getVersion(1); +$version = $objMod->getVersion(0); +$versiontrans = ''; +if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"'); +if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"'); +if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"'); +$versiontrans .= $objMod->getVersion(1); // Define imginfo -$imginfo="info"; +$imginfo = "info"; if ($objMod->isCoreOrExternalModule() == 'external') { - $imginfo="info_black"; + $imginfo = "info_black"; } // Define text of description of module -$text=''; +$text = ''; if ($mode == 'desc') { if ($moduledesc) $text .= '
'.$moduledesc.'


'; - $text.=''.$langs->trans("Version").': '.$version; + $text .= ''.$langs->trans("Version").': '.$version; - $textexternal=''; + $textexternal = ''; if ($objMod->isCoreOrExternalModule() == 'external') { - $textexternal.='
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule", $dirofmodule); - if ($objMod->editor_name != 'dolibarr') $textexternal.='
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name); + $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule", $dirofmodule); + if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); $editor_url = $objMod->editor_url; - if (! preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; - if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal.= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; - $text.=$textexternal; - $text.='
'; + if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; + if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; + $text .= $textexternal; + $text .= '
'; } else { - $text.='
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; + $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; } - $moduledesclong=$objMod->getDescLong(); - if ($moduledesclong) $text.='

'.$moduledesclong.'
'; + $moduledesclong = $objMod->getDescLong(); + if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; } if ($mode == 'feature') { - $text.='
'.$langs->trans("DependsOn").': '; - if (count($objMod->depends)) $text.=join(',', $objMod->depends); - else $text.=$langs->trans("None"); - $text.='
'.$langs->trans("RequiredBy").': '; - if (count($objMod->requiredby)) $text.=join(',', $objMod->requiredby); - else $text.=$langs->trans("None"); + $text .= '
'.$langs->trans("DependsOn").': '; + if (count($objMod->depends)) $text .= join(',', $objMod->depends); + else $text .= $langs->trans("None"); + $text .= '
'.$langs->trans("RequiredBy").': '; + if (count($objMod->requiredby)) $text .= join(',', $objMod->requiredby); + else $text .= $langs->trans("None"); - $text.='

'; + $text .= '

'; - $text.='
'.$langs->trans("AddDataTables").': '; + $text .= '
'.$langs->trans("AddDataTables").': '; $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql')); if (count($sqlfiles) > 0) { - $text.=$langs->trans("Yes").' ('; - $i=0; - foreach($sqlfiles as $val) + $text .= $langs->trans("Yes").' ('; + $i = 0; + foreach ($sqlfiles as $val) { - $text.=($i?', ':'').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); + $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); $i++; } - $text.=')'; + $text .= ')'; } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddDictionaries").': '; + $text .= '
'.$langs->trans("AddDictionaries").': '; if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) { - $i=0; - foreach($objMod->dictionaries['tablib'] as $val) + $i = 0; + foreach ($objMod->dictionaries['tablib'] as $val) { - $text.=($i?', ':'').$val; + $text .= ($i ? ', ' : '').$val; $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddData").': '; + $text .= '
'.$langs->trans("AddData").': '; $filedata = dol_buildpath($moduledir.'/sql/data.sql'); if (dol_is_file($filedata)) { - $text.=$langs->trans("Yes").' ('.$moduledir.'/sql/data.sql'.')'; + $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql'.')'; } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddRemoveTabs").': '; + $text .= '
'.$langs->trans("AddRemoveTabs").': '; if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) { - $i=0; - foreach($objMod->tabs as $val) + $i = 0; + foreach ($objMod->tabs as $val) { - if (is_array($val)) $val=$val['data']; + if (is_array($val)) $val = $val['data']; if (is_string($val)) { - $tmp=explode(':', $val, 3); - $text.=($i?', ':'').$tmp[0].':'.$tmp[1]; + $tmp = explode(':', $val, 3); + $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; $i++; } } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddModels").': '; + $text .= '
'.$langs->trans("AddModels").': '; if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) { - $text.=$langs->trans("Yes"); + $text .= $langs->trans("Yes"); } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddSubstitutions").': '; + $text .= '
'.$langs->trans("AddSubstitutions").': '; if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) { - $text.=$langs->trans("Yes"); + $text .= $langs->trans("Yes"); } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddSheduledJobs").': '; + $text .= '
'.$langs->trans("AddSheduledJobs").': '; if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) { - $i=0; - foreach($objMod->cronjobs as $val) + $i = 0; + foreach ($objMod->cronjobs as $val) { - $text.=($i?', ':'').($val['label']); + $text .= ($i ? ', ' : '').($val['label']); $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddTriggers").': '; - $moreinfoontriggerfile=''; + $text .= '
'.$langs->trans("AddTriggers").': '; + $moreinfoontriggerfile = ''; if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) { - $yesno='Yes'; + $yesno = 'Yes'; } else { - $yesno='No'; + $yesno = 'No'; } require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); - $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external')?'/'.$moduledir:'').'/core/triggers')); - foreach($triggers as $triggercursor) + $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); + foreach ($triggers as $triggercursor) { if ($triggercursor['module'] == $moduledir) { - $yesno='Yes'; - $moreinfoontriggerfile=' ('.$triggercursor['relpath'].')'; + $yesno = 'Yes'; + $moreinfoontriggerfile = ' ('.$triggercursor['relpath'].')'; } } - $text.=$langs->trans($yesno).$moreinfoontriggerfile; + $text .= $langs->trans($yesno).$moreinfoontriggerfile; - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddBoxes").': '; + $text .= '
'.$langs->trans("AddBoxes").': '; if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) { - $i=0; - foreach($objMod->boxes as $val) + $i = 0; + foreach ($objMod->boxes as $val) { - $text.=($i?', ':'').($val['file']?$val['file']:$val[0]); + $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddHooks").': '; + $text .= '
'.$langs->trans("AddHooks").': '; if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) { - $i=0; - foreach($objMod->module_parts['hooks'] as $key => $val) + $i = 0; + foreach ($objMod->module_parts['hooks'] as $key => $val) { if ($key === 'entity') continue; @@ -494,9 +494,9 @@ if ($mode == 'feature') { if (is_array($val)) { - foreach($val as $value) + foreach ($val as $value) { - $text.=($i?', ':'').($value); + $text .= ($i ? ', ' : '').($value); $i++; } @@ -504,75 +504,75 @@ if ($mode == 'feature') } } - $text.=($i?', ':'').($val); + $text .= ($i ? ', ' : '').($val); $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddPermissions").': '; + $text .= '
'.$langs->trans("AddPermissions").': '; if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) { - $i=0; - foreach($objMod->rights as $val) + $i = 0; + foreach ($objMod->rights as $val) { - $text.=($i?', ':'').($val[1]); + $text .= ($i ? ', ' : '').($val[1]); $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddMenus").': '; - if (isset($objMod->menu) && ! empty($objMod->menu)) // objMod can be an array or just an int 1 + $text .= '
'.$langs->trans("AddMenus").': '; + if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 { - $text.=$langs->trans("Yes"); + $text .= $langs->trans("Yes"); } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddExportProfiles").': '; + $text .= '
'.$langs->trans("AddExportProfiles").': '; if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) { - $i=0; - foreach($objMod->export_label as $val) + $i = 0; + foreach ($objMod->export_label as $val) { - $text.=($i?', ':'').($val); + $text .= ($i ? ', ' : '').($val); $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddImportProfiles").': '; + $text .= '
'.$langs->trans("AddImportProfiles").': '; if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) { - $i=0; - foreach($objMod->import_label as $val) + $i = 0; + foreach ($objMod->import_label as $val) { - $text.=($i?', ':'').($val); + $text .= ($i ? ', ' : '').($val); $i++; } } - else $text.=$langs->trans("No"); + else $text .= $langs->trans("No"); - $text.='
'; + $text .= '
'; - $text.='
'.$langs->trans("AddOtherPagesOrServices").': '; - $text.=$langs->trans("DetectionNotPossible"); + $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; + $text .= $langs->trans("DetectionNotPossible"); } if ($mode == 'changelog') { - $changelog=$objMod->getChangeLog(); - if ($changelog) $text.='
'.$changelog.'
'; - else $text.='
'.$langs->trans("NotAvailable").'
'; + $changelog = $objMod->getChangeLog(); + if ($changelog) $text .= '
'.$changelog.'
'; + else $text .= '
'.$langs->trans("NotAvailable").'
'; } print $text; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index e33db21a2b5..9608b0270a3 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1010,19 +1010,19 @@ if ($mode == 'deploy') { dol_fiche_head($head, $mode, '', -1); - $dolibarrdataroot=preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT); - $allowonlineinstall=true; - $allowfromweb=1; - if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false; + $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT); + $allowonlineinstall = true; + $allowfromweb = 1; + if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall = false; - $fullurl=''.$urldolibarrmodules.''; - $message=''; - if (! empty($allowonlineinstall)) + $fullurl = ''.$urldolibarrmodules.''; + $message = ''; + if (!empty($allowonlineinstall)) { - if (! in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) + if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) { - $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); - $allowfromweb=-1; + $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); + $allowfromweb = -1; } else { @@ -1031,21 +1031,21 @@ if ($mode == 'deploy') if (!is_writable(dol_osencode($dirins))) { $langs->load("errors"); - $message=info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning'); - $allowfromweb=0; + $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning'); + $allowfromweb = 0; } } else { - $message=info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); - $allowfromweb=0; + $message = info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + $allowfromweb = 0; } } } else { - $message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock')); - $allowfromweb=0; + $message = info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock')); + $allowfromweb = 0; } if ($allowfromweb < 1) diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index 85c07be8428..d4886bb2a57 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -25,27 +25,27 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$action=GETPOST('action', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminaccoutant'; // To manage different context of search +$action = GETPOST('action', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search // Load translation files required by the page $langs->loadLangs(array('admin', 'companies', 'other')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$error=0; +$error = 0; /* * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) -|| ($action == 'updateedit') ) +if (($action == 'update' && !GETPOST("cancel", 'alpha')) +|| ($action == 'updateedit')) { dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_MONDAY", GETPOST("monday", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_TUESDAY", GETPOST("tuesday", 'alpha'), 'chaine', 0, '', $conf->entity); @@ -55,7 +55,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SATURDAY", GETPOST("saturday", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SUNDAY", GETPOST('sunday', 'alpha'), 'chaine', 0, '', $conf->entity); - if ($action != 'updateedit' && ! $error) + if ($action != 'updateedit' && !$error) { header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -68,7 +68,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) $form = new Form($db); -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("CompanyFoundation"), $help_url); print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); @@ -95,37 +95,37 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') print '
'."\n"; + print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; print ''."\n"; + print ''."\n"; print ''."\n"; + print ''."\n"; print ''."\n"; + print ''."\n"; print ''."\n"; + print ''."\n"; print ''."\n"; + print ''."\n"; print ''."\n"; + print ''."\n"; print '
'; print ''; print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."".$objp->societe."
'; print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>
'; print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print '
'; print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print '
'; print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print '
'; print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print '
'; print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print '
'; print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); print ''; - print '
'; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index dddf914a957..e740150e1d5 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -29,13 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "errors", "bills")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='invoice'; +$type = 'invoice'; if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada.php'; @@ -46,13 +46,13 @@ if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_pay if ($action == 'updateMask') { - $maskconstpayment=GETPOST('maskconstpayment', 'alpha'); - $maskpayment=GETPOST('maskpayment', 'alpha'); + $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskpayment = GETPOST('maskpayment', 'alpha'); if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -69,17 +69,17 @@ if ($action == 'setmod') if ($action == 'setparams') { - $freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; if ($error) { setEventMessages($langs->trans("Error"), null, 'errors'); } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -90,14 +90,14 @@ if ($action == 'setparams') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); @@ -129,24 +129,24 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility - if (! is_file($dir.$filebis)) + if (!is_file($dir.$filebis)) { $filebis = $file."/".$file.".modules.php"; $classname = "mod_payment_".$file; } // Check if there is a filter on country preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; $classname = preg_replace('/\-.*$/', '', $classname); - if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') { // Charging the numbering class require_once $dir.$filebis; @@ -154,7 +154,7 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -170,9 +170,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -188,21 +188,21 @@ foreach ($dirmodels as $reldir) } print ''; - $payment=new Paiement($db); + $payment = new Paiement($db); $payment->initAsSpecimen(); // Example - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $payment); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=$langs->trans("NextValue").': '; + $htmltooltip .= $langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors { - if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); } print ''; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index b11f909bd37..60bd157d283 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -35,7 +35,7 @@ $action = GETPOST('action', 'aZ09'); if (!$user->admin) accessforbidden(); -$entity=$conf->entity; +$entity = $conf->entity; /* @@ -168,8 +168,8 @@ if ($result) $family = $modules[$obj->module]->family_position; $familyposition = 0; $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; - $sqlupdate.= " family_position = ".$familyposition; - $sqlupdate.= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; + $sqlupdate .= " family_position = ".$familyposition; + $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; $db->query($sqlupdate); } } diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 12231079ae0..e9795304ad3 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","withdrawals")); +$langs->loadLangs(array("admin", "withdrawals")); // Security check if (!$user->admin) accessforbidden(); @@ -48,12 +48,12 @@ if ($action == "set") { $db->begin(); - $id=GETPOST('PRELEVEMENT_ID_BANKACCOUNT', 'int'); + $id = GETPOST('PRELEVEMENT_ID_BANKACCOUNT', 'int'); $account = new Account($db); - if($account->fetch($id)>0) + if ($account->fetch($id) > 0) { $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; /* $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; @@ -74,29 +74,29 @@ if ($action == "set") else $error++; $res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; if (GETPOST("PRELEVEMENT_USER") > 0) { $res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } - if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END")=="") + if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") { $res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } - if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD")=="") + if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") { $res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } - if (GETPOST("PRELEVEMENT_ADDDAYS") || GETPOST("PRELEVEMENT_ADDDAYS")=="") + if (GETPOST("PRELEVEMENT_ADDDAYS") || GETPOST("PRELEVEMENT_ADDDAYS") == "") { $res = dolibarr_set_const($db, "PRELEVEMENT_ADDDAYS", GETPOST("PRELEVEMENT_ADDDAYS"), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - } elseif (! $error) + if (!$res > 0) $error++; + } elseif (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -196,13 +196,13 @@ elseif ($action == 'setdoc') * View */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader('', $langs->trans("WithdrawalsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("WithdrawalsSetup"), $linkback, 'title_setup'); print '
'; @@ -251,7 +251,7 @@ print ''; //ADDDAYS print ''.$langs->trans("ADDDAYS").''; print ''; -if (! $conf->global->PRELEVEMENT_ADDDAYS) $conf->global->PRELEVEMENT_ADDDAYS=0; +if (!$conf->global->PRELEVEMENT_ADDDAYS) $conf->global->PRELEVEMENT_ADDDAYS = 0; print ''; print ''; print ''; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 9011c6b4e67..bf1283daa6d 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -31,7 +31,7 @@ $langs->loadLangs(array("other", "users", "admin")); if (!$user->admin) accessforbidden(); -$upload_dir=$conf->admin->dir_temp; +$upload_dir = $conf->admin->dir_temp; /* @@ -40,31 +40,31 @@ $upload_dir=$conf->admin->dir_temp; if (GETPOST('action', 'aZ09') == 'set_proxy') { - if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && ! is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) + if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) { setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors'); $error++; } - if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && ! is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) + if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) { setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors'); $error++; } - if (! $error) + if (!$error) { - $result=0; - $result+=dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity); - $result+=dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity); - $result+=dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine', 0, '', $conf->entity); - $result+=dolibarr_set_const($db, 'MAIN_PROXY_HOST', GETPOST("MAIN_PROXY_HOST"), 'chaine', 0, '', $conf->entity); - $result+=dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity); - $result+=dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity); - $result+=dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity); + $result = 0; + $result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity); + $result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity); + $result += dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine', 0, '', $conf->entity); + $result += dolibarr_set_const($db, 'MAIN_PROXY_HOST', GETPOST("MAIN_PROXY_HOST"), 'chaine', 0, '', $conf->entity); + $result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity); + $result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity); + $result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity); if ($result < 5) dol_print_error($db); } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } @@ -77,7 +77,7 @@ if (GETPOST('action', 'aZ09') == 'set_proxy') $form = new Form($db); -$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("Proxy"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); @@ -92,7 +92,7 @@ print ''; print ''; -$head=security_prepare_head(); +$head = security_prepare_head(); dol_fiche_head($head, 'proxy', $langs->trans("Security"), -1); @@ -135,7 +135,7 @@ print ''; print ''.$langs->trans("ConnectionTimeout").''; print ''; print ''; -print 'global->MAIN_USE_CONNECT_TIMEOUT).'">'; +print 'global->MAIN_USE_CONNECT_TIMEOUT).'">'; print ' '.strtolower($langs->trans("Seconds")); print ''; print ''; diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 78b82f42b82..8730f148c07 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/receiptprinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","receiptprinter")); +$langs->loadLangs(array("admin", "receiptprinter")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -49,7 +49,7 @@ $templateid = GETPOST('templateid', 'int'); $printer = new dolReceiptPrinter($db); -if (!$mode) $mode='config'; +if (!$mode) $mode = 'config'; // used in library escpos maybe useful if php doesn't support gzdecode if (!function_exists('gzdecode')) { @@ -70,7 +70,7 @@ if (!function_exists('gzdecode')) { */ if ($action == 'addprinter' && $user->admin) { - $error=0; + $error = 0; $db->begin(); if (empty($printername)) { $error++; @@ -81,11 +81,11 @@ if ($action == 'addprinter' && $user->admin) { setEventMessages($langs->trans("PrinterParameterEmpty"), null, 'warnings'); } - if (! $error) { - $result= $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); + if (!$error) { + $result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); if ($result > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PrinterAdded", $printername), null); @@ -100,18 +100,18 @@ if ($action == 'addprinter' && $user->admin) { } if ($action == 'deleteprinter' && $user->admin) { - $error=0; + $error = 0; $db->begin(); if (empty($printerid)) { $error++; setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); } - if (! $error) { - $result= $printer->deletePrinter($printerid); + if (!$error) { + $result = $printer->deletePrinter($printerid); if ($result > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PrinterDeleted", $printername), null); @@ -126,18 +126,18 @@ if ($action == 'deleteprinter' && $user->admin) { } if ($action == 'updateprinter' && $user->admin) { - $error=0; + $error = 0; $db->begin(); if (empty($printerid)) { $error++; setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); } - if (! $error) { - $result= $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); + if (!$error) { + $result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); if ($result > 0) $error++; - if (! $error) { + if (!$error) { $db->commit(); setEventMessages($langs->trans("PrinterUpdated", $printername), null); } else { @@ -149,13 +149,13 @@ if ($action == 'updateprinter' && $user->admin) { } if ($action == 'testprinter' && $user->admin) { - $error=0; + $error = 0; if (empty($printerid)) { $error++; setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); } - if (! $error) { + if (!$error) { // test $ret = $printer->sendTestToPrinter($printerid); if ($ret == 0) { @@ -168,7 +168,7 @@ if ($action == 'testprinter' && $user->admin) { } if ($action == 'testtemplate' && $user->admin) { - $error=0; + $error = 0; // if (empty($printerid)) { // $error++; // setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); @@ -192,18 +192,18 @@ if ($action == 'testtemplate' && $user->admin) { } if ($action == 'updatetemplate' && $user->admin) { - $error=0; + $error = 0; $db->begin(); if (empty($templateid)) { $error++; setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors'); } - if (! $error) { - $result= $printer->updateTemplate($templatename, $template, $templateid); + if (!$error) { + $result = $printer->updateTemplate($templatename, $template, $templateid); if ($result > 0) $error++; - if (! $error) { + if (!$error) { $db->commit(); setEventMessages($langs->trans("TemplateUpdated", $templatename), null); } else { @@ -215,18 +215,18 @@ if ($action == 'updatetemplate' && $user->admin) { } if ($action == 'addtemplate' && $user->admin) { - $error=0; + $error = 0; $db->begin(); if (empty($templatename)) { $error++; setEventMessages($langs->trans("TemplateNameEmpty"), null, 'errors'); } - if (! $error) { - $result= $printer->addTemplate($templatename, $template); + if (!$error) { + $result = $printer->addTemplate($templatename, $template); if ($result > 0) $error++; - if (! $error) { + if (!$error) { $db->commit(); setEventMessages($langs->trans("TemplateAdded", $templatename), null); } else { @@ -246,7 +246,7 @@ $form = new Form($db); llxHeader('', $langs->trans("ReceiptPrinterSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ReceiptPrinterSetup"), $linkback, 'title_setup'); $head = receiptprinteradmin_prepare_head($mode); @@ -254,7 +254,7 @@ $head = receiptprinteradmin_prepare_head($mode); if ($mode == 'config' && $user->admin) { print ''; print ''; - if ($action!='editprinter') { + if ($action != 'editprinter') { print ''; } else { print ''; @@ -278,9 +278,9 @@ if ($mode == 'config' && $user->admin) { if ($ret > 0) { setEventMessages($printer->error, $printer->errors, 'errors'); } else { - for ($line=0; $line < $nbofprinters; $line++) { + for ($line = 0; $line < $nbofprinters; $line++) { print ''; - if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) { + if ($action == 'editprinter' && $printer->listprinters[$line]['rowid'] == $printerid) { print ''; print ''; $ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']); @@ -339,7 +339,7 @@ if ($mode == 'config' && $user->admin) { dol_fiche_end(); - if ($action!='editprinter') { + if ($action != 'editprinter') { print '
'; } else { print '
'; @@ -377,7 +377,7 @@ if ($mode == 'config' && $user->admin) { if ($mode == 'template' && $user->admin) { print ''; print ''; - if ($action!='edittemplate') { + if ($action != 'edittemplate') { print ''; } else { print ''; @@ -400,9 +400,9 @@ if ($mode == 'template' && $user->admin) { setEventMessages($printer->error, $printer->errors, 'errors'); } else { $max = count($printer->listprinterstemplates); - for ($line=0; $line < $max; $line++) { + for ($line = 0; $line < $max; $line++) { print ''; - if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) { + if ($action == 'edittemplate' && $printer->listprinterstemplates[$line]['rowid'] == $templateid) { print ''; print ''; print ''; @@ -429,7 +429,7 @@ if ($mode == 'template' && $user->admin) { } print ''; - if ($action!='edittemplate') { + if ($action != 'edittemplate') { print ''; print ''; print ''; @@ -448,7 +448,7 @@ if ($mode == 'template' && $user->admin) { print ''.$langs->trans("Description").''; print "\n"; $max = count($printer->tags); - for ($tag=0; $tag < $max; $tag++) { + for ($tag = 0; $tag < $max; $tag++) { print ''; print '<'.$printer->tags[$tag].'>'.$langs->trans(strtoupper($printer->tags[$tag])).''; print ''; diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index 95338903ade..ce5cbcd7179 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -46,13 +46,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='reception'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'reception'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -69,11 +69,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Receptions"); +$textobject = $langs->transnoentitiesnoconv("Receptions"); llxHeader('', $langs->trans("ReceptionsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ReceptionsSetup"), $linkback, 'title_setup'); print "
\n"; @@ -114,7 +114,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index b64c01c5f00..3efdd05bdc7 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -28,10 +28,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; -if (! empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; +if (!empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","resource")); +$langs->loadLangs(array("admin", "resource")); // Security check if (!$user->admin) @@ -65,10 +65,10 @@ llxHeader('', $langs->trans('ResourceSetup')); $form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ResourceSetup'), $linkback, 'title_setup'); -$head=resource_admin_prepare_head(); +$head = resource_admin_prepare_head(); dol_fiche_head($head, 'general', $langs->trans("ResourceSingular"), -1, 'action'); @@ -95,7 +95,7 @@ if (empty($conf->use_javascript_ajax)) else { print ''; - $arrval=array( + $arrval = array( '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index 12e9ff58c8a..57eaa0d245c 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -40,13 +40,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='resource'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'resource'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -63,15 +63,15 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("ResourceSingular"); +$textobject = $langs->transnoentitiesnoconv("ResourceSingular"); llxHeader('', $langs->trans("ResourceSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ResourceSetup"), $linkback, 'title_setup'); print "
\n"; -$head=resource_admin_prepare_head(); +$head = resource_admin_prepare_head(); dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), -1, 'action'); @@ -108,7 +108,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 4a70104158b..09cc0debfd5 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -304,23 +304,23 @@ else // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - $formsms->fromtype='user'; - $formsms->fromid=$user->id; - $formsms->fromsms = (isset($_POST['fromsms'])?$_POST['fromsms']:($conf->global->MAIN_MAIL_SMS_FROM?$conf->global->MAIN_MAIL_SMS_FROM:$user->user_mobile)); - $formsms->withfromreadonly=0; - $formsms->withsubstit=0; - $formsms->withfrom=1; - $formsms->withto=(isset($_POST['sendto'])?$_POST['sendto']:$user->user_mobile?$user->user_mobile:1); - $formsms->withbody=(isset($_POST['message'])?(empty($_POST['message'])?1:$_POST['message']):$langs->trans("ThisIsATestMessage")); - $formsms->withbodyreadonly=0; - $formsms->withcancel=1; + $formsms->fromtype = 'user'; + $formsms->fromid = $user->id; + $formsms->fromsms = (isset($_POST['fromsms']) ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); + $formsms->withfromreadonly = 0; + $formsms->withsubstit = 0; + $formsms->withfrom = 1; + $formsms->withto = (isset($_POST['sendto']) ? $_POST['sendto'] : $user->user_mobile ? $user->user_mobile : 1); + $formsms->withbody = (isset($_POST['message']) ? (empty($_POST['message']) ? 1 : $_POST['message']) : $langs->trans("ThisIsATestMessage")); + $formsms->withbodyreadonly = 0; + $formsms->withcancel = 1; // Tableau des substitutions - $formsms->substit=$substitutionarrayfortest; + $formsms->substit = $substitutionarrayfortest; // Tableau des parametres complementaires du post - $formsms->param["action"]="send"; - $formsms->param["models"]="body"; - $formsms->param["smsid"]=0; - $formsms->param["returnurl"]=$_SERVER["PHP_SELF"]; + $formsms->param["action"] = "send"; + $formsms->param["models"] = "body"; + $formsms->param["smsid"] = 0; + $formsms->param["returnurl"] = $_SERVER["PHP_SELF"]; $formsms->show_form(); diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index af72c3c8ace..d2a92aed9e8 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "errors")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$type=array('yesno','texte','chaine'); +$type = array('yesno', 'texte', 'chaine'); $action = GETPOST('action', 'aZ09'); @@ -43,7 +43,7 @@ $action = GETPOST('action', 'aZ09'); */ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -57,7 +57,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -74,16 +74,16 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) * View */ -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("SocialNetworkSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SocialNetworkSetup"), $linkback, 'title_setup'); //$head = socialnetworks_admin_prepare_head(); -$h=0; +$h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php'; $head[$h][1] = $langs->trans("Setup"); @@ -97,9 +97,9 @@ dol_fiche_head($head, 'setup', '', 0, 'user'); print '
'; -$arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); +$arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); -foreach($arrayofsocialnetworks as $snkey => $snlabel) { +foreach ($arrayofsocialnetworks as $snkey => $snlabel) { $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); if ($conf->use_javascript_ajax) { $link = ajax_constantonoff($consttocheck); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 0b6987b1a9f..43e610c3052 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha'); */ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -57,7 +57,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -75,21 +75,21 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) llxHeader('', $langs->trans("StockSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("StockSetup"), $linkback, 'title_setup'); $head = stock_admin_prepare_head(); dol_fiche_head($head, 'general', $langs->trans("StockSetup"), -1, 'stock'); -$form=new Form($db); +$form = new Form($db); -$disabled=''; -if (! empty($conf->productbatch->enabled)) +$disabled = ''; +if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); - $disabled=' disabled'; + $disabled = ' disabled'; print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced")); } @@ -106,12 +106,12 @@ print "".$langs->trans("RuleForStockManagementDecrease")."\n"; print ''.$langs->trans("Status").''."\n"; print ''."\n"; -$found=0; +$found = 0; print ''; print ''.$langs->trans("DeStockOnBill").''; print ''; -if (! empty($conf->facture->enabled)) +if (!empty($conf->facture->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_BILL'); @@ -131,7 +131,7 @@ $found++; print ''; print ''.$langs->trans("DeStockOnValidateOrder").''; print ''; -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER'); @@ -153,7 +153,7 @@ $found++; print ''; print ''.$langs->trans("DeStockOnShipment").''; print ''; -if (! empty($conf->expedition->enabled)) +if (!empty($conf->expedition->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT'); @@ -173,7 +173,7 @@ $found++; print ''; print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; -if (! empty($conf->expedition->enabled)) +if (!empty($conf->expedition->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE'); @@ -208,12 +208,12 @@ print "".$langs->trans("RuleForStockManagementIncrease")."\n"; print ''.$langs->trans("Status").''."\n"; print ''."\n"; -$found=0; +$found = 0; print ''; print ''.$langs->trans("ReStockOnBill").''; print ''; -if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)) +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL'); @@ -234,7 +234,7 @@ $found++; print ''; print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; -if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)) +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'); @@ -285,7 +285,7 @@ else print ''; print ''.$langs->trans("ReStockOnDispatchOrder").''; print ''; - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'); @@ -334,7 +334,7 @@ print "\n"; print "\n"; // Option to force stock to be enough before adding a line into document -if($conf->invoice->enabled) +if ($conf->invoice->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForInvoice").''; @@ -349,7 +349,7 @@ if($conf->invoice->enabled) print "\n"; } -if($conf->order->enabled) +if ($conf->order->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForOrder").''; @@ -364,7 +364,7 @@ if($conf->order->enabled) print "\n"; } -if($conf->expedition->enabled) +if ($conf->expedition->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForShipment").''; @@ -382,12 +382,12 @@ print ''; print '
'; -$virtualdiffersfromphysical=0; +$virtualdiffersfromphysical = 0; if ( - ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) - || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) + !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) + || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } if ($virtualdiffersfromphysical) diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 20c6f3f66a8..172f243a22c 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -41,13 +41,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='facture_fourn'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'facture_fourn'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -64,11 +64,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("BillsSuppliers"); +$textobject = $langs->transnoentitiesnoconv("BillsSuppliers"); llxHeader('', $langs->trans("SuppliersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); print "
\n"; @@ -109,7 +109,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 39a757bbf9c..a9fa9c1b09d 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -43,13 +43,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='facture_fourn_det'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'facture_fourn_det'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -66,11 +66,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("BillsSuppliers"); +$textobject = $langs->transnoentitiesnoconv("BillsSuppliers"); llxHeader('', $langs->trans("SuppliersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); print "
\n"; @@ -111,7 +111,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 8924741df52..c280e56ac86 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -41,13 +41,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='commande_fournisseur'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'commande_fournisseur'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -64,11 +64,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("SuppliersOrders"); +$textobject = $langs->transnoentitiesnoconv("SuppliersOrders"); llxHeader('', $langs->trans("SuppliersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); print "
\n"; @@ -109,7 +109,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 737742f2b95..59cc6783db8 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -42,13 +42,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='commande_fournisseurdet'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'commande_fournisseurdet'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -65,11 +65,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("SuppliersOrders"); +$textobject = $langs->transnoentitiesnoconv("SuppliersOrders"); llxHeader('', $langs->trans("SuppliersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); print "
\n"; @@ -110,7 +110,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index c597f82a79d..16b273cd6db 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -32,15 +32,15 @@ global $conf; if (!$user->admin) accessforbidden(); // Load translation files required by the page -$langs->loadLangs(array("admin","other")); +$langs->loadLangs(array("admin", "other")); -$error=0; +$error = 0; $action = GETPOST('action', 'aZ09'); $syslogModules = array(); $activeModules = array(); -if (! empty($conf->global->SYSLOG_HANDLERS)) $activeModules = json_decode($conf->global->SYSLOG_HANDLERS); +if (!empty($conf->global->SYSLOG_HANDLERS)) $activeModules = json_decode($conf->global->SYSLOG_HANDLERS); $dirsyslogs = array_merge(array('/core/modules/syslog/'), $conf->modules_parts['syslog']); foreach ($dirsyslogs as $reldir) { @@ -54,7 +54,7 @@ foreach ($dirsyslogs as $reldir) { if (substr($file, 0, 11) == 'mod_syslog_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); - require_once $newdir . $file . '.php'; + require_once $newdir.$file.'.php'; $module = new $file; @@ -109,7 +109,7 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); // Check configuration @@ -122,7 +122,7 @@ if ($action == 'set') } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -141,18 +141,18 @@ if ($action == 'setlevel') $res = dolibarr_set_const($db, "SYSLOG_LEVEL", $level, 'chaine', 0, '', 0); dol_syslog("admin/syslog: level ".$level); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $file_saves = GETPOST("file_saves"); $res = dolibarr_set_const($db, "SYSLOG_FILE_SAVES", $file_saves, 'chaine', 0, '', 0); dol_syslog("admin/syslog: file saves ".$file_saves); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -168,19 +168,19 @@ if ($action == 'setlevel') llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SyslogSetup"), $linkback, 'title_setup'); print '
'; $def = array(); -$syslogfacility=$defaultsyslogfacility=dolibarr_get_const($db, "SYSLOG_FACILITY", 0); -$syslogfile=$defaultsyslogfile=dolibarr_get_const($db, "SYSLOG_FILE", 0); +$syslogfacility = $defaultsyslogfacility = dolibarr_get_const($db, "SYSLOG_FACILITY", 0); +$syslogfile = $defaultsyslogfile = dolibarr_get_const($db, "SYSLOG_FILE", 0); -if (! $defaultsyslogfacility) $defaultsyslogfacility='LOG_USER'; -if (! $defaultsyslogfile) $defaultsyslogfile='dolibarr.log'; +if (!$defaultsyslogfacility) $defaultsyslogfacility = 'LOG_USER'; +if (!$defaultsyslogfile) $defaultsyslogfile = 'dolibarr.log'; if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity) { @@ -208,9 +208,9 @@ foreach ($syslogModules as $moduleName) { $module = new $moduleName; - $moduleactive=(int) $module->isActive(); + $moduleactive = (int) $module->isActive(); //print $moduleName." = ".$moduleactive." - ".$module->getName()." ".($moduleactive == -1)."
\n"; - if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL)) continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them) + if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL)) continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them) print ''; @@ -220,27 +220,27 @@ foreach ($syslogModules as $moduleName) print ''; print ''; - $setuparray=$module->configure(); + $setuparray = $module->configure(); if ($setuparray) { foreach ($setuparray as $option) { - $tmpoption=$option['constant']; - if (! empty($tmpoption)) + $tmpoption = $option['constant']; + if (!empty($tmpoption)) { - if (isset($_POST[$tmpoption])) $value=$_POST[$tmpoption]; - elseif (! empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; + if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; + elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; } else $value = (isset($option['default']) ? $option['default'] : ''); print $option['name'].': '; - if (! empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; + if (!empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/', $value)) { - $filelogparam =' ('; - $filelogparam.=$langs->trans('Download'); - $filelogparam.=$filelog.')'; + $filelogparam = ' ('; + $filelogparam .= $langs->trans('Download'); + $filelogparam .= $filelog.')'; print $filelogparam; } } @@ -279,18 +279,18 @@ print "\n"; print ''.$langs->trans("SyslogLevel").''; print ''; print ''; -if(! empty($conf->loghandlers['mod_syslog_file']) && ! empty($conf->cron->enabled)) { +if (!empty($conf->loghandlers['mod_syslog_file']) && !empty($conf->cron->enabled)) { print ''.$langs->trans("SyslogFileNumberOfSaves").''; print ''; print ' ('.$langs->trans('ConfigureCleaningCronjobToSetFrequencyOfSaves').')'; diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index 3cfc18accc9..3d0dddd6d10 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -29,14 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("help","members","other","admin")); +$langs->loadLangs(array("help", "members", "other", "admin")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $sfurl = ''; -$version='0.0'; +$version = '0.0'; /* @@ -148,9 +148,9 @@ print ''; print $langs->trans("Foundation").':'; print '
    '; -$url='https://wiki.dolibarr.org/index.php/Subscribe'; -if (preg_match('/^fr_/i', $langs->getDefaultLang())) $url='https://wiki.dolibarr.org/index.php/Adh%C3%A9rer'; -if (preg_match('/^es_/i', $langs->getDefaultLang())) $url='https://wiki.dolibarr.org/index.php/Subscribirse'; +$url = 'https://wiki.dolibarr.org/index.php/Subscribe'; +if (preg_match('/^fr_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Adh%C3%A9rer'; +if (preg_match('/^es_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Subscribirse'; print '
  • '.$langs->trans("SubscribeToFoundation").'
  • '; print '
'; @@ -167,13 +167,13 @@ print ''; print $langs->trans("OtherResources").':'; print '
    '; -$url='https://saas.dolibarr.org'; $title=$langs->trans("OfficialWebHostingService"); -if (preg_match('/^fr_/i', $langs->getDefaultLang())) $url='https://wiki.dolibarr.org/index.php/Solutions_de_Cloud'; -if (preg_match('/^es_/i', $langs->getDefaultLang())) $url='https://wiki.dolibarr.org/index.php/Soluciones_en_la_Nube'; +$url = 'https://saas.dolibarr.org'; $title = $langs->trans("OfficialWebHostingService"); +if (preg_match('/^fr_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Solutions_de_Cloud'; +if (preg_match('/^es_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Soluciones_en_la_Nube'; print '
  • '; print ''.$title.''; print '
  • '; -$url='https://partners.dolibarr.org'; $title=$langs->trans("ReferencedPreferredPartners"); +$url = 'https://partners.dolibarr.org'; $title = $langs->trans("ReferencedPreferredPartners"); print '
  • '; print ''.$title.''; print '
  • '; @@ -185,10 +185,10 @@ print '
'; print '
'; -$showpromotemessage=1; +$showpromotemessage = 1; if ($showpromotemessage) { - $tmp=versiondolibarrarray(); + $tmp = versiondolibarrarray(); if (is_numeric($tmp[2])) // Not alpha, beta or rc { print '
'; diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php index cae6e568d65..db64acdcf28 100644 --- a/htdocs/admin/system/browser.php +++ b/htdocs/admin/system/browser.php @@ -27,9 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install","other","admin")); +$langs->loadLangs(array("install", "other", "admin")); -if (! $user->admin) +if (!$user->admin) accessforbidden(); @@ -37,13 +37,13 @@ if (! $user->admin) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); print load_fiche_titre($langs->trans("InfoBrowser"), '', 'title_setup'); -$tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); +$tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); // Browser print '
'; @@ -55,8 +55,8 @@ print ''.$langs->trans("BrowserOS").''.$langs->trans("Version").''.$tmp['browserversion'].''."\n"; print ''.$langs->trans("Layout").' (phone/tablet/classic)'.$tmp['layout'].''."\n"; print ''.$langs->trans("IPAddress").''.dol_escape_htmltag($_SERVER['REMOTE_ADDR']); -if (! empty($_SERVER['HTTP_CLIENT_IP'])) print ' (HTTP_CLIENT_IP='.dol_escape_htmltag($_SERVER['HTTP_CLIENT_IP']).')'; -if (! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) print ' (HTTP_X_FORWARDED_FOR='.dol_escape_htmltag($_SERVER['HTTP_X_FORWARDED_FOR']).')'; +if (!empty($_SERVER['HTTP_CLIENT_IP'])) print ' (HTTP_CLIENT_IP='.dol_escape_htmltag($_SERVER['HTTP_CLIENT_IP']).')'; +if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) print ' (HTTP_X_FORWARDED_FOR='.dol_escape_htmltag($_SERVER['HTTP_X_FORWARDED_FOR']).')'; print ''."\n"; print ''.$langs->trans("SessionName").''.session_name().''."\n"; print ''.$langs->trans("SessionId").''.session_id().''."\n"; diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index 0835138227b..c52af371dbc 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -25,7 +25,7 @@ require '../../main.inc.php'; // Load translation files required by the page -$langs->loadLangs(array("install","user","admin")); +$langs->loadLangs(array("install", "user", "admin")); if (!$user->admin) @@ -43,7 +43,7 @@ print load_fiche_titre($langs->trans("SummaryConst"), '', 'title_setup'); print load_fiche_titre($langs->trans("ConfigurationFile").' ('.$conffiletoshowshort.')'); // Parameters in conf.php file (when a parameter start with ?, it is shown only if defined) -$configfileparameters=array( +$configfileparameters = array( 'dolibarr_main_url_root', 'dolibarr_main_url_root_alt', 'dolibarr_main_document_root', @@ -92,7 +92,7 @@ $configfileparameters=array( '?dolibarr_mailing_limit_sendbycli', '?dolibarr_strict_mode' ); -$configfilelib=array( +$configfilelib = array( // 'separator', $langs->trans("URLRoot"), $langs->trans("URLRoot").' (alt)', @@ -145,13 +145,13 @@ print ''.$langs->trans("Label").''; print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print ''."\n"; -$i=0; -foreach($configfileparameters as $key) +$i = 0; +foreach ($configfileparameters as $key) { - $ignore=0; + $ignore = 0; - if ($key == 'dolibarr_main_url_root_alt' && empty(${$key})) $ignore=1; - if ($key == 'dolibarr_main_document_root_alt' && empty(${$key})) $ignore=1; + if ($key == 'dolibarr_main_url_root_alt' && empty(${$key})) $ignore = 1; + if ($key == 'dolibarr_main_document_root_alt' && empty(${$key})) $ignore = 1; if (empty($ignore)) { @@ -160,7 +160,7 @@ foreach($configfileparameters as $key) if (preg_match('/^\?/', $key) && empty(${$newkey})) { $i++; - continue; // We discard parametes starting with ? + continue; // We discard parametes starting with ? } if ($newkey == 'separator' && $lastkeyshown == 'separator') @@ -189,7 +189,7 @@ foreach($configfileparameters as $key) print ""; } print "\n"; - $lastkeyshown=$newkey; + $lastkeyshown = $newkey; } $i++; } @@ -204,28 +204,28 @@ print ''; print ''; print ''; print ''; -if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled +if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled print "\n"; $sql = "SELECT"; -$sql.= " rowid"; -$sql.= ", ".$db->decrypt('name')." as name"; -$sql.= ", ".$db->decrypt('value')." as value"; -$sql.= ", type"; -$sql.= ", note"; -$sql.= ", entity"; -$sql.= " FROM ".MAIN_DB_PREFIX."const"; +$sql .= " rowid"; +$sql .= ", ".$db->decrypt('name')." as name"; +$sql .= ", ".$db->decrypt('value')." as value"; +$sql .= ", type"; +$sql .= ", note"; +$sql .= ", entity"; +$sql .= " FROM ".MAIN_DB_PREFIX."const"; if (empty($conf->multicompany->enabled)) { // If no multicompany mode, admins can see global and their constantes - $sql.= " WHERE entity IN (0,".$conf->entity.")"; + $sql .= " WHERE entity IN (0,".$conf->entity.")"; } else { // If multicompany mode, superadmin (user->entity=0) can see everything, admin are limited to their entities. - if ($user->entity) $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; + if ($user->entity) $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; } -$sql.= " ORDER BY entity, name ASC"; +$sql .= " ORDER BY entity, name ASC"; $resql = $db->query($sql); if ($resql) { @@ -239,7 +239,7 @@ if ($resql) print ''; print ''."\n"; print ''."\n"; - if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled + if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled print "\n"; $i++; diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index dfd05a7694e..ef62c9aa34e 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -35,7 +35,7 @@ if (!$user->admin) accessforbidden(); * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); @@ -47,9 +47,9 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Entity").''.$langs->trans("Entity").'
'.$obj->name.''.$obj->value.''.$obj->entity.''.$obj->entity.'
'; print ''."\n"; print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -66,17 +66,17 @@ print ''."\n"; // arraytest is an array of test to do - $arraytest=array(); + $arraytest = array(); if (preg_match('/mysql/i', $db->type)) { - $arraytest=array( - 'character_set_database'=>array('var'=>'dolibarr_main_db_character_set','valifempty'=>'utf8'), - 'collation_database'=>array('var'=>'dolibarr_main_db_collation','valifempty'=>'utf8_unicode_ci') + $arraytest = array( + 'character_set_database'=>array('var'=>'dolibarr_main_db_character_set', 'valifempty'=>'utf8'), + 'collation_database'=>array('var'=>'dolibarr_main_db_collation', 'valifempty'=>'utf8_unicode_ci') ); } - $listtouse=array(); - if ($listname == 'listofvars') $listtouse=$listofvars; - if ($listname == 'listofstatus') $listtouse=$listofstatus; + $listtouse = array(); + if ($listname == 'listofvars') $listtouse = $listofvars; + if ($listname == 'listofstatus') $listtouse = $listofstatus; - foreach($listtouse as $param => $paramval) + foreach ($listtouse as $param => $paramval) { print ''; print ''; print ''; print ''."\n"; } diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index 7195fd42869..90f788f3825 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -28,10 +28,10 @@ require '../../main.inc.php'; $langs->load("admin"); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$table=GETPOST('table', 'alpha'); +$table = GETPOST('table', 'alpha'); /* @@ -41,22 +41,22 @@ $table=GETPOST('table', 'alpha'); llxHeader(); -print load_fiche_titre($langs->trans("Table") . " ".$table, '', 'title_setup'); +print load_fiche_titre($langs->trans("Table")." ".$table, '', 'title_setup'); // Define request to get table description -$base=0; +$base = 0; if (preg_match('/mysql/i', $conf->db->type)) { $sql = "SHOW TABLE STATUS LIKE '".$db->escape($table)."'"; - $base=1; + $base = 1; } elseif ($conf->db->type == 'pgsql') { $sql = "SELECT conname,contype FROM pg_constraint"; - $base=2; + $base = 2; } -if (! $base) +if (!$base) { print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver"); } @@ -66,7 +66,7 @@ else if ($resql) { $num = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); @@ -76,11 +76,11 @@ else if ($base == 1) // mysql { - $link=array(); + $link = array(); $cons = explode(";", $row[14]); - if (! empty($cons)) + if (!empty($cons)) { - foreach($cons as $cc) + foreach ($cons as $cc) { $cx = preg_replace("/\)\sREFER/", "", $cc); $cx = preg_replace("/\(`/", "", $cx); @@ -89,8 +89,8 @@ else $val = explode("`", $cx); - $link[trim($val[0])][0] = (isset($val[1])?$val[1]:''); - $link[trim($val[0])][1] = (isset($val[2])?$val[2]:''); + $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] : ''); + $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] : ''); } } @@ -113,7 +113,7 @@ else if ($resql) { $num = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); @@ -121,13 +121,13 @@ else print ""; print ""; print ""; - print ""; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; + print ""; - print ""; + print ""; print ''; print ''; diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 88f8a7ca968..0796d934a74 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -396,7 +396,7 @@ foreach ($configfileparameters as $key => $value) { //print $conf->file->instance_unique_id; global $dolibarr_main_cookie_cryptkey; - $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey + $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey print $valuetoshow; if (empty($valuetoshow)) { print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index dce23de6270..61de00287e9 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -26,9 +26,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install","other","admin")); +$langs->loadLangs(array("install", "other", "admin")); -if (! $user->admin) +if (!$user->admin) accessforbidden(); @@ -50,13 +50,13 @@ $modules_fullpath = array(); $modulesdir = dolGetModulesDirs(); // Load list of modules -$i=0; -foreach($modulesdir as $dir) +$i = 0; +foreach ($modulesdir as $dir) { - $handle=@opendir(dol_osencode($dir)); + $handle = @opendir(dol_osencode($dir)); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { @@ -73,19 +73,19 @@ foreach($modulesdir as $dir) else { // File to load - $res=include_once $dir.$file; + $res = include_once $dir.$file; if (class_exists($modName)) { try { $objMod = new $modName($db); - $modules[$objMod->numero]=$objMod; - $modules_names[$objMod->numero]=$objMod->name; - $modules_files[$objMod->numero]=$file; - $modules_fullpath[$file]=$dir.$file; - $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic'; + $modules[$objMod->numero] = $objMod; + $modules_names[$objMod->numero] = $objMod->name; + $modules_files[$objMod->numero] = $file; + $modules_fullpath[$file] = $dir.$file; + $picto[$objMod->numero] = (isset($objMod->picto) && $objMod->picto) ? $objMod->picto : 'generic'; } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } @@ -110,17 +110,17 @@ print ''; print ''; print ''; print ''; -$var=false; -$sortorder=$modules_names; +$var = false; +$sortorder = $modules_names; ksort($sortorder); $rights_ids = array(); -foreach($sortorder as $numero=>$name) +foreach ($sortorder as $numero=>$name) { - $idperms=""; + $idperms = ""; // Module print ''; + print ''; print "\n"; } print '
'.$langs->trans("Database").'
'.$langs->trans("Version").''.$db::LABEL.' '.$db->getVersion().'
'.$langs->trans("DatabaseServer").''.$conf->db->host.'
'.$langs->trans("DatabasePort").''.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'
'.$langs->trans("DatabasePort").''.(empty($conf->db->port) ? $langs->trans("Default") : $conf->db->port).'
'.$langs->trans("DatabaseName").''.$conf->db->name.'
'.$langs->trans("DriverType").''.$conf->db->type . ($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')':'').'
'.$langs->trans("DriverType").''.$conf->db->type.($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')' : '').'
'.$langs->trans("User").''.$conf->db->user.'
'.$langs->trans("Password").''.preg_replace('/./i', '*', $dolibarr_main_db_pass).'
'.$langs->trans("DBStoringCharset").''.$db->getDefaultCharacterSetDatabase().'
'; print '
'; @@ -87,37 +87,37 @@ else print '
'; print $param; print ''; - $show=0;$text=''; - foreach($arraytest as $key => $val) + $show = 0; $text = ''; + foreach ($arraytest as $key => $val) { if ($key != $param) continue; - $val2=${$val['var']}; - $text='Should be in line with value of param '.$val['var'].' thas is '.($val2?$val2:"'' (=".$val['valifempty'].")").''; - $show=1; + $val2 = ${$val['var']}; + $text = 'Should be in line with value of param '.$val['var'].' thas is '.($val2 ? $val2 : "'' (=".$val['valifempty'].")").''; + $show = 1; } - if ($show==0) print $paramval; - if ($show==1) print $form->textwithpicto($paramval, $text); - if ($show==2) print $form->textwithpicto($paramval, $text, 1, 'warning'); + if ($show == 0) print $paramval; + if ($show == 1) print $form->textwithpicto($paramval, $text); + if ($show == 2) print $form->textwithpicto($paramval, $text, 1, 'warning'); print '
".$row[0]."".$row[1]."".$row[3]."".(empty($row[4])?'':$row[4])."".(empty($row[5])?'':$row[5])."".(empty($row[6])?'':$row[6])."".(empty($row[7])?'':$row[7])."".(empty($row[4]) ? '' : $row[4])."".(empty($row[5]) ? '' : $row[5])."".(empty($row[6]) ? '' : $row[6])."".(empty($row[7]) ? '' : $row[7])."".(isset($link[$row[0]][0])?$link[$row[0]][0]:'')."."; - print (isset($link[$row[0]][1])?$link[$row[0]][1]:'')."".(isset($link[$row[0]][0]) ? $link[$row[0]][0] : '')."."; + print (isset($link[$row[0]][1]) ? $link[$row[0]][1] : '')."
'.$langs->trans("Version").''.$langs->trans("IdModule").''.$langs->trans("IdPermissions").'
'; - $alt=$name.' - '.$modules_files[$numero]; - if (! empty($picto[$numero])) + $alt = $name.' - '.$modules_files[$numero]; + if (!empty($picto[$numero])) { if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1); else print img_object($alt, $picto[$numero], 'width="14px"'); @@ -138,21 +138,21 @@ foreach($sortorder as $numero=>$name) // Permissions if ($modules[$numero]->rights) { - foreach($modules[$numero]->rights as $rights) + foreach ($modules[$numero]->rights as $rights) { - $idperms.=($idperms?", ":"").$rights[0]; + $idperms .= ($idperms ? ", " : "").$rights[0]; array_push($rights_ids, $rights[0]); } } - print ''.($idperms?$idperms:" ").''.($idperms ? $idperms : " ").'
'; print '
'; print '
'; sort($rights_ids); -$old=''; -foreach($rights_ids as $right_id) +$old = ''; +foreach ($rights_ids as $right_id) { if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."
"; $old = $right_id; diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php index d171fcaa2ec..9b37b7fa4b4 100644 --- a/htdocs/admin/system/os.php +++ b/htdocs/admin/system/os.php @@ -45,7 +45,7 @@ print "\n"; print ''.$langs->trans("PHP_OS")."".PHP_OS."\n"; // Recupere la version de l'OS -$osversion=version_os(); +$osversion = version_os(); print ''.$langs->trans("Version")."".$osversion."\n"; print ''; diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 42c66281450..fcfe25ce3d3 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -27,9 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install","other","admin")); +$langs->loadLangs(array("install", "other", "admin")); -if (! $user->admin) +if (!$user->admin) accessforbidden(); if (GETPOST('action', 'aZ09') == 'donothing') @@ -42,8 +42,8 @@ if (GETPOST('action', 'aZ09') == 'donothing') * View */ -$form=new Form($db); -$nowstring=dol_print_date(dol_now(), 'dayhourlog'); +$form = new Form($db); +$nowstring = dol_print_date(dol_now(), 'dayhourlog'); llxHeader(); @@ -52,7 +52,7 @@ print load_fiche_titre($langs->trans("PerfDolibarr"), '', 'title_setup'); print $langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; // Recupere la version de PHP -$phpversion=version_php(); +$phpversion = version_php(); print "
PHP - ".$langs->trans("Version").": ".$phpversion."
\n"; // Recupere la version du serveur web @@ -61,7 +61,7 @@ print "
Web server - ".$langs->trans("Version").": ".$_SERVE // XDebug print '
'; print ''.$langs->trans("XDebug").': '; -$test=!function_exists('xdebug_is_enabled'); +$test = !function_exists('xdebug_is_enabled'); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { @@ -73,7 +73,7 @@ print '
'; // Module log print '
'; print ''.$langs->trans("Syslog").': '; -$test=empty($conf->syslog->enabled); +$test = empty($conf->syslog->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { @@ -85,7 +85,7 @@ print '
'; // Module debugbar print '
'; print ''.$langs->trans("DebugBar").': '; -$test=empty($conf->debugbar->enabled); +$test = empty($conf->debugbar->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { @@ -97,7 +97,7 @@ print '
'; // Applicative cache print '
'; print ''.$langs->trans("ApplicativeCache").': '; -$test=!empty($conf->memcached->enabled); +$test = !empty($conf->memcached->enabled); if ($test) { if (!empty($conf->global->MEMCACHED_SERVER)) @@ -117,30 +117,30 @@ print '
'; // OPCode cache print '
'; print ''.$langs->trans("OPCodeCache").': '; -$foundcache=0; -$test=function_exists('xcache_info'); -if (! $foundcache && $test) +$foundcache = 0; +$test = function_exists('xcache_info'); +if (!$foundcache && $test) { $foundcache++; print img_picto('', 'tick.png').' '.$langs->trans("PHPModuleLoaded", "XCache"); print ' '.$langs->trans("MoreInformation").' Xcache admin page'; } -$test=function_exists('eaccelerator_info'); -if (! $foundcache && $test) +$test = function_exists('eaccelerator_info'); +if (!$foundcache && $test) { $foundcache++; print img_picto('', 'tick.png').' '.$langs->trans("PHPModuleLoaded", "Eaccelerator"); } -$test=function_exists('opcache_get_status'); -if (! $foundcache && $test) +$test = function_exists('opcache_get_status'); +if (!$foundcache && $test) { $foundcache++; - print img_picto('', 'tick.png').' '.$langs->trans("PHPModuleLoaded", "ZendOPCache"); // Should be by default starting with PHP 5.5 + print img_picto('', 'tick.png').' '.$langs->trans("PHPModuleLoaded", "ZendOPCache"); // Should be by default starting with PHP 5.5 //$tmp=opcache_get_status(); //var_dump($tmp); } -$test=function_exists('apc_cache_info'); -if (! $foundcache && $test) +$test = function_exists('apc_cache_info'); +if (!$foundcache && $test) { //var_dump(apc_cache_info()); if (ini_get('apc.enabled')) @@ -153,7 +153,7 @@ if (! $foundcache && $test) print img_picto('', 'warning').' '.$langs->trans("APCCacheInstalledButDisabled"); } } -if (! $foundcache) print $langs->trans("NoOPCodeCacheFound"); +if (!$foundcache) print $langs->trans("NoOPCodeCacheFound"); print '
'; // Use of preload bootstrap @@ -464,7 +464,7 @@ print ''.$langs->trans("DriverType").': '; print '
'; if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { - $test=($conf->db->type == 'mysqli'); + $test = ($conf->db->type == 'mysqli'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("YouUseBestDriver", $conf->db->type); @@ -482,14 +482,14 @@ print ''.$langs->trans("SearchOptim").': '; print '
'; $tab = array(); $sql = "SELECT COUNT(*) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +$resql = $db->query($sql); if ($resql) { - $limitforoptim=10000; - $num=$db->num_rows($resql); - $obj=$db->fetch_object($resql); - $nb=$obj->nb; + $limitforoptim = 10000; + $num = $db->num_rows($resql); + $obj = $db->fetch_object($resql); + $nb = $obj->nb; if ($nb > $limitforoptim) { if (empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) @@ -512,14 +512,14 @@ if ($resql) // Thirdparty search $tab = array(); $sql = "SELECT COUNT(*) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$resql = $db->query($sql); if ($resql) { - $limitforoptim=10000; - $num=$db->num_rows($resql); - $obj=$db->fetch_object($resql); - $nb=$obj->nb; + $limitforoptim = 10000; + $num = $db->num_rows($resql); + $obj = $db->fetch_object($resql); + $nb = $obj->nb; if ($nb > $limitforoptim) { if (empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) @@ -542,7 +542,7 @@ if ($resql) // Browser print '
'; print ''.$langs->trans("Browser").':
'; -if (! in_array($conf->browser->name, array('chrome','opera','safari','firefox'))) +if (!in_array($conf->browser->name, array('chrome', 'opera', 'safari', 'firefox'))) { print img_picto('', 'warning.png').' '.$langs->trans("BrowserIsKO", $conf->browser->name); } diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 9471a682116..db9a893ff9f 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -32,7 +32,7 @@ $langs->load("admin"); $langs->load("install"); $langs->load("errors"); -if (! $user->admin) +if (!$user->admin) accessforbidden(); @@ -43,7 +43,7 @@ if (! $user->admin) llxHeader(); -$title='InfoPHP'; +$title = 'InfoPHP'; if (isset($title)) { @@ -52,16 +52,16 @@ if (isset($title)) // Check PHP setup is OK -$maxphp=@ini_get('upload_max_filesize'); // In unknown -if (preg_match('/k$/i', $maxphp)) $maxphp=$maxphp*1; -if (preg_match('/m$/i', $maxphp)) $maxphp=$maxphp*1024; -if (preg_match('/g$/i', $maxphp)) $maxphp=$maxphp*1024*1024; -if (preg_match('/t$/i', $maxphp)) $maxphp=$maxphp*1024*1024*1024; -$maxphp2=@ini_get('post_max_size'); // In unknown -if (preg_match('/k$/i', $maxphp2)) $maxphp2=$maxphp2*1; -if (preg_match('/m$/i', $maxphp2)) $maxphp2=$maxphp2*1024; -if (preg_match('/g$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024; -if (preg_match('/t$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024*1024; +$maxphp = @ini_get('upload_max_filesize'); // In unknown +if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; +if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; +if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; +if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; +$maxphp2 = @ini_get('post_max_size'); // In unknown +if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; +if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; +if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; +if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) { $langs->load("errors"); @@ -79,8 +79,8 @@ $OkayPicturePath = "../../theme/eldy/img/tick.png"; print ''.$langs->trans("Version").''; -$arrayphpminversionerror = array(5,5,0); -$arrayphpminversionwarning = array(5,6,0); +$arrayphpminversionerror = array(5, 5, 0); +$arrayphpminversionwarning = array(5, 6, 0); if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) { @@ -98,7 +98,7 @@ else print ''; print 'GET and POST support'; -if (! isset($_GET["testget"]) && ! isset($_POST["testpost"]) && ! isset($_GET["mainmenu"])) +if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); print ' ('.$langs->trans("Recheck").')'; @@ -111,7 +111,7 @@ else print ''; print 'Sessions support'; -if (! function_exists("session_id")) +if (!function_exists("session_id")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportSessions"); } @@ -123,7 +123,7 @@ else print ''; print 'UTF-8 support'; -if (! function_exists("utf8_encode")) +if (!function_exists("utf8_encode")) { print 'Warning '.$langs->trans("ErrorPHPDoesNotSupportUTF8"); } @@ -202,8 +202,8 @@ print ''; print '
'; // Get php_info array -$phparray=phpinfo_array(); -foreach($phparray as $key => $value) +$phparray = phpinfo_array(); +foreach ($phparray as $key => $value) { print '
'; print ''; @@ -214,18 +214,18 @@ foreach($phparray as $key => $value) print "\n"; //var_dump($value); - foreach($value as $keyparam => $keyvalue) + foreach ($value as $keyparam => $keyvalue) { - if (! is_array($keyvalue)) + if (!is_array($keyvalue)) { print ''; print ''; - $valtoshow=$keyvalue; - if ($keyparam == 'X-ChromePhp-Data') $valtoshow=dol_trunc($keyvalue, 80); + $valtoshow = $keyvalue; + if ($keyparam == 'X-ChromePhp-Data') $valtoshow = dol_trunc($keyvalue, 80); print ''; print ''; @@ -234,12 +234,12 @@ foreach($phparray as $key => $value) { print ''; print ''; - $i=0; - foreach($keyvalue as $keyparam2 => $keyvalue2) + $i = 0; + foreach ($keyvalue as $keyparam2 => $keyvalue2) { print '"; } @@ -374,12 +374,12 @@ function getTableColumnFunction(array $functions) $result = true; $html = ""; + $html .= $result ? $langs->trans("PHPSupport".$name) : $langs->trans("ErrorPHPDoesNotSupport".$name); + $html .= ""; return $html; } diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php index 5061305f2e2..c63e8e0f1de 100644 --- a/htdocs/admin/system/xcache.php +++ b/htdocs/admin/system/xcache.php @@ -26,7 +26,7 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); /* diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index 9ea68431b1a..5e4e9eff82f 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -49,8 +49,8 @@ if (!function_exists('xdebug_is_enabled')) if (function_exists('socket_create')) { - $address = ini_get('xdebug.remote_host')?ini_get('xdebug.remote_host'):'127.0.0.1'; - $port = ini_get('xdebug.remote_port')?ini_get('xdebug.remote_port'):9000; + $address = ini_get('xdebug.remote_host') ?ini_get('xdebug.remote_host') : '127.0.0.1'; + $port = ini_get('xdebug.remote_port') ?ini_get('xdebug.remote_port') : 9000; print "Current xdebug setup:
\n"; print "* Remote debug setup:
\n"; @@ -58,7 +58,7 @@ if (function_exists('socket_create')) print 'xdebug.remote_host = '.$address."
\n"; print 'xdebug.remote_port = '.$port."
\n"; print "* Profiler setup "; - if (function_exists('xdebug_get_profiler_filename')) print xdebug_get_profiler_filename()?"(currently on into file ".xdebug_get_profiler_filename().")":"(currently off)"; + if (function_exists('xdebug_get_profiler_filename')) print xdebug_get_profiler_filename() ? "(currently on into file ".xdebug_get_profiler_filename().")" : "(currently off)"; else print "(currenlty not available)"; print ":
\n"; print 'xdebug.profiler_enable = '.ini_get('xdebug.profiler_enable')."
\n"; @@ -80,7 +80,7 @@ if (function_exists('socket_create')) //socket_bind($sock, $address, $port) or die('Unable to bind on address='.$address.' port='.$port); //socket_listen($sock); //$client = socket_accept($sock); - $client=socket_connect($socket, $address, $port); + $client = socket_connect($socket, $address, $port); if ($client) { echo "Connection established: ".$client." - address=".$address." port=".$port."
\n"; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index c4bf602217a..f9bb8f39641 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -26,8 +26,8 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'objects', 'companies', 'products')); @@ -54,7 +54,7 @@ $action = GETPOST('action', 'alpha'); // Product On delivery On delivery // Service On invoice On invoice -$tax_mode = empty($conf->global->TAX_MODE)?0:$conf->global->TAX_MODE; +$tax_mode = empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE; if ($action == 'update') { $error = 0; @@ -65,7 +65,7 @@ if ($action == 'update') { $db->begin(); $res = dolibarr_set_const($db, 'TAX_MODE', $tax_mode, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; switch ($tax_mode) { @@ -90,19 +90,19 @@ if ($action == 'update') { } $res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', $valuesellproduct, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; $res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', $valuebuyproduct, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; $res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $valuesellservice, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; $res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $valuebuyservice, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_VAT_RETURN", GETPOST("MAIN_INFO_VAT_RETURN", 'alpha'), 'chaine', 0, '', $conf->entity); - if (! $error) { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -119,10 +119,10 @@ if ($action == 'update') { llxHeader('', $langs->trans("TaxSetup")); -$form=new Form($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +$form = new Form($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('TaxSetup'), $linkback, 'title_setup'); //dol_fiche_head(null, '', '', -1); @@ -141,11 +141,11 @@ else print ''; print ''; print ''; - if (! $conf->use_javascript_ajax) + if (!$conf->use_javascript_ajax) { print ''; // Status print ''; @@ -414,7 +414,7 @@ print ''; // Action column print ''; @@ -435,7 +435,7 @@ print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="c print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder, '')."\n"; print ''; -if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { +if (!empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { // This is version that is faster but require more memory and report errors that are outside the filter range // TODO Make a full scan of table in reverse order of id of $block, so we can use the parameter $previoushash into checkSignature to save requests @@ -444,17 +444,17 @@ if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { else { // This is version that optimize the memory (but will not report errors that are outside the filter range) - $loweridinerror=0; - $checkresult=array(); + $loweridinerror = 0; + $checkresult = array(); if (is_array($blocks)) { - foreach($blocks as &$block) + foreach ($blocks as &$block) { - $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various - $checkresult[$block->id]=$checksignature; // false if error - if (! $checksignature) + $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various + $checkresult[$block->id] = $checksignature; // false if error + if (!$checksignature) { - if (empty($loweridinerror)) $loweridinerror=$block->id; + if (empty($loweridinerror)) $loweridinerror = $block->id; else $loweridinerror = min($loweridinerror, $block->id); } } @@ -463,12 +463,12 @@ else if (is_array($blocks)) { - foreach($blocks as &$block) + foreach ($blocks as &$block) { $object_link = $block->getObjectLink(); //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) - if (empty($search_showonlyerrors) || ! $checkresult[$block->id]) + if (empty($search_showonlyerrors) || !$checkresult[$block->id]) { print ''; @@ -506,7 +506,7 @@ if (is_array($blocks)) // Status print ''; @@ -572,7 +572,7 @@ jQuery(document).ready(function () { '."\n"; -if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { ?> '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), 'enable'=>$langs->trans("Enable"), 'disable'=>$langs->trans("Disable"), ); if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 6b629fd2852..d21d82b5ca9 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -63,16 +63,16 @@ class Boms extends DolibarrApi */ public function get($id) { - if (! DolibarrApiAccess::$user->rights->bom->read) { + if (!DolibarrApiAccess::$user->rights->bom->read) { throw new RestException(401); } $result = $this->bom->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'BOM not found'); } - if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { + if (!DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -103,27 +103,27 @@ class Boms extends DolibarrApi $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; - $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object + $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; + $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= " WHERE 1 = 1"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= " WHERE 1 = 1"; // Example of use $mode //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')'; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($restrictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; - if ($restrictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($tmpobject->ismultientitymanaged) $sql .= ' AND t.entity IN ('.getEntity('bom').')'; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($restrictonsocid && $socid) $sql .= " AND t.fk_soc = ".$socid; + if ($restrictonsocid && $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($restrictonsocid && $search_sale > 0) { @@ -131,23 +131,23 @@ class Boms extends DolibarrApi } if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); @@ -168,7 +168,7 @@ class Boms extends DolibarrApi else { throw new RestException(503, 'Error when retrieve bom list'); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No bom found'); } return $obj_ret; @@ -182,16 +182,16 @@ class Boms extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->bom->write) { + if (!DolibarrApiAccess::$user->rights->bom->write) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->bom->$field = $value; } - if( ! $this->bom->create(DolibarrApiAccess::$user)) { + if (!$this->bom->create(DolibarrApiAccess::$user)) { throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } return $this->bom->id; @@ -207,25 +207,25 @@ class Boms extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->bom->write) { + if (!DolibarrApiAccess::$user->rights->bom->write) { throw new RestException(401); } $result = $this->bom->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'BOM not found'); } - if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { + if (!DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->bom->$field = $value; } - if($this->bom->update($id, DolibarrApiAccess::$user) > 0) + if ($this->bom->update($id, DolibarrApiAccess::$user) > 0) { return $this->get($id); } @@ -243,19 +243,19 @@ class Boms extends DolibarrApi */ public function delete($id) { - if (! DolibarrApiAccess::$user->rights->bom->delete) { + if (!DolibarrApiAccess::$user->rights->bom->delete) { throw new RestException(401); } $result = $this->bom->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'BOM not found'); } - if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { + if (!DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! $this->bom->delete(DolibarrApiAccess::$user)) + if (!$this->bom->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error); } @@ -318,9 +318,9 @@ class Boms extends DolibarrApi unset($object->location_incoterms); // If object has lines, remove $db property - if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { $nboflines = count($object->lines); - for ($i=0; $i < $nboflines; $i++) + for ($i = 0; $i < $nboflines; $i++) { $this->_cleanObjectDatas($object->lines[$i]); @@ -344,7 +344,7 @@ class Boms extends DolibarrApi { $myobject = array(); foreach ($this->bom->fields as $field => $propfield) { - if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field + if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $myobject[$field] = $data[$field]; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index c2779429ebc..a9ed7ee3a00 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1009,7 +1009,7 @@ class BOM extends CommonObject */ public function calculateCosts() { - include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $this->unit_cost = 0; $this->total_cost = 0; diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 7da2c768b7f..92f43ec3fce 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -90,19 +90,19 @@ function bomPrepareHead($object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bom->dir_output."/bom/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 66bcf0cece5..be7eb3e775f 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -130,7 +130,7 @@ print ''; $coldisplay++; print ''; $coldisplay++; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index c8899603f58..36862e48708 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -52,11 +52,11 @@ $objectline = new BOMLine($this->db); print "\n"; -$coldisplay=0; +$coldisplay = 0; print ''; // Adds a line numbering column -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; $coldisplay++; } @@ -82,8 +82,8 @@ if ($line->fk_product > 0) { if (is_object($hookmanager)) { $fk_parent_line = (GETPOST('fk_parent_line') ? GETPOST('fk_parent_line') : $line->fk_parent_line); - $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); - $reshook=$hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action); + $parameters = array('line'=>$line, 'fk_parent_line'=>$fk_parent_line, 'var'=>$var, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer); + $reshook = $hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action); } print ''; @@ -104,7 +104,7 @@ if (($line->info_bits & 2) != 2) { // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; - print ''; + print ''; } print ''; @@ -117,20 +117,20 @@ if ($conf->global->PRODUCT_USE_UNITS) } $coldisplay++; -print ''; $coldisplay++; -print ''; $coldisplay++; print ''; -$coldisplay+=$colspan; +$coldisplay += $colspan; print '\n"; print ''; // Adds a line numbering column -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ''; // Description print ''; @@ -71,7 +71,7 @@ print ''; -print ''; // No width to allow autodim +print ''; // No width to allow autodim print ''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1419136a2e8..667c66848ae 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -95,7 +95,7 @@ echo $line->qty_frozen ? yn($line->qty_frozen) : ''; print ''; print ''; print ''; -if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { +if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { print ''; - print ''; print ''; diff --git a/htdocs/compta/bank/bilan.php b/htdocs/compta/bank/bilan.php index 28607ecca26..d728ac2a71b 100644 --- a/htdocs/compta/bank/bilan.php +++ b/htdocs/compta/bank/bilan.php @@ -44,10 +44,10 @@ function valeur($sql) $valeur = 0; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $valeur = $obj->amount; $db->free($resql); } diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index a4c57a60fdd..042117808d5 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -31,15 +31,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories')); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque'); /* * View */ -$companystatic=new Societe($db); +$companystatic = new Societe($db); llxHeader(); @@ -55,14 +55,14 @@ print ''; print "\n"; $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid "; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; -$sql.= ", ".MAIN_DB_PREFIX."bank_class as l"; -$sql.= ", ".MAIN_DB_PREFIX."bank as d"; -$sql.= " WHERE c.entity = ".$conf->entity; -$sql.= " AND c.rowid = l.fk_categ"; -$sql.= " AND d.rowid = l.lineid"; -$sql.= " GROUP BY c.label, c.rowid"; -$sql.= " ORDER BY c.label"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; +$sql .= ", ".MAIN_DB_PREFIX."bank_class as l"; +$sql .= ", ".MAIN_DB_PREFIX."bank as d"; +$sql .= " WHERE c.entity = ".$conf->entity; +$sql .= " AND c.rowid = l.fk_categ"; +$sql .= " AND d.rowid = l.lineid"; +$sql .= " GROUP BY c.label, c.rowid"; +$sql .= " ORDER BY c.label"; $result = $db->query($sql); if ($result) @@ -88,7 +88,7 @@ if ($result) print ''; print ''; - print ''; + print ''; } else { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 60d7c4f2463..cba83d8f015 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1188,34 +1188,34 @@ class Account extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT b.rowid, b.datev as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.rappro=0"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable - $sql.= " AND clos = 0"; - if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.rappro=0"; + $sql .= " AND b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql .= " AND clos = 0"; + if ($filteraccountid) $sql .= " AND ba.rowid = ".$filteraccountid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $langs->load("banks"); - $now=dol_now(); + $now = dol_now(); require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; $response = new WorkboardResponse(); - $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; - $response->label=$langs->trans("TransactionsToConciliate"); + $response->warning_delay = $conf->bank->rappro->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("TransactionsToConciliate"); $response->labelShort = $langs->trans("TransactionsToConciliateShort"); - $response->url=DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&mainmenu=bank'; - $response->img=img_object('', "payment"); + $response->url = DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&mainmenu=bank'; + $response->img = img_object('', "payment"); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) { @@ -1244,30 +1244,30 @@ class Account extends CommonObject // phpcs:enable global $user; - if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT count(b.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable - $sql.= " AND clos = 0"; - if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql .= " AND clos = 0"; + if ($filteraccountid) $sql .= " AND ba.rowid = ".$filteraccountid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["banklines"]=$obj->nb; + $this->nb["banklines"] = $obj->nb; } $this->db->free($resql); } else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 1272cfcad85..2fb97ff949c 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -66,32 +66,32 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (! DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('bank_account').')'; + $sql .= ' WHERE t.entity IN ('.getEntity('bank_account').')'; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $this->db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -108,7 +108,7 @@ class BankAccounts extends DolibarrApi } } } else { - throw new RestException(503, 'Error when retrieving list of accounts: ' . $this->db->lasterror()); + throw new RestException(503, 'Error when retrieving list of accounts: '.$this->db->lasterror()); } return $list; @@ -124,13 +124,13 @@ class BankAccounts extends DolibarrApi */ public function get($id) { - if (! DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -145,7 +145,7 @@ class BankAccounts extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } // Check mandatory fields @@ -190,7 +190,7 @@ class BankAccounts extends DolibarrApi */ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } @@ -235,14 +235,14 @@ class BankAccounts extends DolibarrApi $user = DolibarrApiAccess::$user; // By default, electronic transfert from bank to bank - $typefrom='PRE'; - $typeto='VIR'; + $typefrom = 'PRE'; + $typeto = 'VIR'; if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { // This is transfer of change - $typefrom='LIQ'; - $typeto='LIQ'; + $typefrom = 'LIQ'; + $typeto = 'LIQ'; } /** @@ -250,7 +250,7 @@ class BankAccounts extends DolibarrApi */ if (!$error) { - $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1*price2num($amount), '', '', $user); + $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user); } if (!($bank_line_id_from > 0)) { $error++; @@ -312,13 +312,13 @@ class BankAccounts extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -345,12 +345,12 @@ class BankAccounts extends DolibarrApi */ public function delete($id) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -378,7 +378,7 @@ class BankAccounts extends DolibarrApi { $account = array(); foreach (BankAccounts::$FIELDS as $field) { - if (! isset($data[$field])) + if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $account[$field] = $data[$field]; } @@ -417,13 +417,13 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (! DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -433,12 +433,12 @@ class BankAccounts extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql .= " ORDER BY rowid"; @@ -455,7 +455,7 @@ class BankAccounts extends DolibarrApi } } } else { - throw new RestException(503, 'Error when retrieving list of account lines: ' . $accountLine->error); + throw new RestException(503, 'Error when retrieving list of account lines: '.$accountLine->error); } return $list; @@ -479,13 +479,13 @@ class BankAccounts extends DolibarrApi */ public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') { - if (! DolibarrApiAccess::$user->rights->banque->modifier) { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -500,7 +500,7 @@ class BankAccounts extends DolibarrApi $cheque_writer, $cheque_bank ); if ($result < 0) { - throw new RestException(503, 'Error when adding line to account: ' . $account->error); + throw new RestException(503, 'Error when adding line to account: '.$account->error); } return $result; } @@ -520,25 +520,25 @@ class BankAccounts extends DolibarrApi */ public function addLink($id, $line_id, $url_id, $url, $label, $type) { - if (! DolibarrApiAccess::$user->rights->banque->modifier) { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } $accountLine = new AccountLine($this->db); $result = $accountLine->fetch($line_id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account line not found'); } $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); if ($result < 0) { - throw new RestException(503, 'Error when adding link to account line: ' . $account->error); + throw new RestException(503, 'Error when adding link to account line: '.$account->error); } return $result; } diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 92e16211ce0..c7e86e51cfb 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -33,7 +33,7 @@ class BankCateg // extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='generic'; + public $picto = 'generic'; /** * @var int ID @@ -211,10 +211,10 @@ class BankCateg // extends CommonObject $this->db->begin(); // Delete link between tag and bank account - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql.= " WHERE fk_categorie = ".$this->id; + $sql .= " WHERE fk_categorie = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -225,10 +225,10 @@ class BankCateg // extends CommonObject } // Delete link between tag and bank lines - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; - $sql.= " WHERE fk_categ = ".$this->id; + $sql .= " WHERE fk_categ = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -239,7 +239,7 @@ class BankCateg // extends CommonObject } // Delete bank categ - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; $sql .= " WHERE rowid=".$this->id; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 58e01ec2f28..6af394ad4b4 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -34,12 +34,12 @@ class PaymentVarious extends CommonObject /** * @var string ID to identify managed object */ - public $element='variouspayment'; + public $element = 'variouspayment'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='payment_various'; + public $table_element = 'payment_various'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -118,12 +118,12 @@ class PaymentVarious extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->amount = trim($this->amount); + $this->label = trim($this->label); + $this->note = trim($this->note); $this->fk_bank = (int) $this->fk_bank; $this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_modif = (int) $this->fk_user_modif; @@ -132,40 +132,40 @@ class PaymentVarious extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET"; - if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',"; - $sql.= " datep='".$this->db->idate($this->datep)."',"; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " sens=".(int) $this->sens.","; - $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_typepayment=".(int) $this->fk_typepayment.","; - $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; - $sql.= " subledger_account='".$this->db->escape($this->subledger_account)."',"; - $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; - $sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").","; - $sql.= " fk_user_author=".(int) $this->fk_user_author.","; - $sql.= " fk_user_modif=".(int) $this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; + if ($this->tms) $sql .= " tms='".$this->db->idate($this->tms)."',"; + $sql .= " datep='".$this->db->idate($this->datep)."',"; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " sens=".(int) $this->sens.","; + $sql .= " amount=".price2num($this->amount).","; + $sql .= " fk_typepayment=".(int) $this->fk_typepayment.","; + $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " note='".$this->db->escape($this->note)."',"; + $sql .= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; + $sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',"; + $sql .= " fk_projet='".$this->db->escape($this->fk_project)."',"; + $sql .= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank : "null").","; + $sql .= " fk_user_author=".(int) $this->fk_user_author.","; + $sql .= " fk_user_modif=".(int) $this->fk_user_modif; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('PAYMENT_VARIOUS_MODIFY', $user); + $result = $this->call_trigger('PAYMENT_VARIOUS_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -189,31 +189,31 @@ class PaymentVarious extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " v.rowid,"; - $sql.= " v.tms,"; - $sql.= " v.datep,"; - $sql.= " v.datev,"; - $sql.= " v.sens,"; - $sql.= " v.amount,"; - $sql.= " v.fk_typepayment,"; - $sql.= " v.num_payment,"; - $sql.= " v.label,"; - $sql.= " v.note,"; - $sql.= " v.accountancy_code,"; - $sql.= " v.subledger_account,"; - $sql.= " v.fk_projet as fk_project,"; - $sql.= " v.fk_bank,"; - $sql.= " v.fk_user_author,"; - $sql.= " v.fk_user_modif,"; - $sql.= " b.fk_account,"; - $sql.= " b.fk_type,"; - $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; - $sql.= " WHERE v.rowid = ".$id; + $sql .= " v.rowid,"; + $sql .= " v.tms,"; + $sql .= " v.datep,"; + $sql .= " v.datev,"; + $sql .= " v.sens,"; + $sql .= " v.amount,"; + $sql .= " v.fk_typepayment,"; + $sql .= " v.num_payment,"; + $sql .= " v.label,"; + $sql .= " v.note,"; + $sql .= " v.accountancy_code,"; + $sql .= " v.subledger_account,"; + $sql .= " v.fk_projet as fk_project,"; + $sql .= " v.fk_bank,"; + $sql .= " v.fk_user_author,"; + $sql .= " v.fk_user_modif,"; + $sql .= " b.fk_account,"; + $sql .= " b.fk_type,"; + $sql .= " b.rappro"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; + $sql .= " WHERE v.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -247,7 +247,7 @@ class PaymentVarious extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -263,22 +263,22 @@ class PaymentVarious extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Call trigger - $result=$this->call_trigger('PAYMENT_VARIOUS_DELETE', $user); + $result = $this->call_trigger('PAYMENT_VARIOUS_DELETE', $user); if ($result < 0) return -1; // End call triggers $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_various"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -295,20 +295,20 @@ class PaymentVarious extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->tms=''; - $this->datep=''; - $this->datev=''; - $this->sens=''; - $this->amount=''; - $this->label=''; - $this->accountancy_code=''; - $this->subledger_account=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_author=''; - $this->fk_user_modif=''; + $this->tms = ''; + $this->datep = ''; + $this->datev = ''; + $this->sens = ''; + $this->amount = ''; + $this->label = ''; + $this->accountancy_code = ''; + $this->subledger_account = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_author = ''; + $this->fk_user_modif = ''; } /** @@ -319,38 +319,38 @@ class PaymentVarious extends CommonObject */ public function create($user) { - global $conf,$langs; + global $conf, $langs; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->amount=price2num(trim($this->amount)); - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); + $this->note = trim($this->note); $this->fk_bank = (int) $this->fk_bank; $this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_modif = (int) $this->fk_user_modif; // Check parameters - if (! $this->label) + if (!$this->label) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } if ($this->amount < 0 || $this->amount == '') { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } - if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); return -6; } - if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -7; } @@ -358,39 +358,39 @@ class PaymentVarious extends CommonObject // Insert into llx_payment_various $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_various ("; - $sql.= " datep"; - $sql.= ", datev"; - $sql.= ", sens"; - $sql.= ", amount"; - $sql.= ", fk_typepayment"; - $sql.= ", num_payment"; - if ($this->note) $sql.= ", note"; - $sql.= ", label"; - $sql.= ", accountancy_code"; - $sql.= ", subledger_account"; - $sql.= ", fk_projet"; - $sql.= ", fk_user_author"; - $sql.= ", datec"; - $sql.= ", fk_bank"; - $sql.= ", entity"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= "'".$this->db->idate($this->datep)."'"; - $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->db->escape($this->sens)."'"; - $sql.= ", ".price2num($this->amount); - $sql.= ", '".$this->db->escape($this->type_payment)."'"; - $sql.= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; - $sql.= ", '".$this->db->escape($this->subledger_account)."'"; - $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); - $sql.= ", ".$user->id; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", NULL"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + $sql .= " datep"; + $sql .= ", datev"; + $sql .= ", sens"; + $sql .= ", amount"; + $sql .= ", fk_typepayment"; + $sql .= ", num_payment"; + if ($this->note) $sql .= ", note"; + $sql .= ", label"; + $sql .= ", accountancy_code"; + $sql .= ", subledger_account"; + $sql .= ", fk_projet"; + $sql .= ", fk_user_author"; + $sql .= ", datec"; + $sql .= ", fk_bank"; + $sql .= ", entity"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= "'".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", '".$this->db->escape($this->sens)."'"; + $sql .= ", ".price2num($this->amount); + $sql .= ", '".$this->db->escape($this->type_payment)."'"; + $sql .= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql .= ", '".$this->db->escape($this->subledger_account)."'"; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", NULL"; + $sql .= ", ".$conf->entity; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -401,19 +401,19 @@ class PaymentVarious extends CommonObject if ($this->id > 0) { - if (! empty($conf->banque->enabled) && ! empty($this->amount)) + if (!empty($conf->banque->enabled) && !empty($this->amount)) { // Insert into llx_bank require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); - $result=$acc->fetch($this->accountid); + $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); // Insert payment into llx_bank // Add link 'payment_various' in bank_url between payment and bank transaction - $sign=1; - if ($this->sens == '0') $sign=-1; + $sign = 1; + if ($this->sens == '0') $sign = -1; $bank_line_id = $acc->addline( $this->datep, @@ -433,38 +433,38 @@ class PaymentVarious extends CommonObject } else { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } - if (! $error) + if (!$error) { // Add link 'payment_various' in bank_url between payment and bank transaction - $url=DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='; + $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='; - $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(VariousPayment)", "payment_various"); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(VariousPayment)", "payment_various"); if ($result <= 0) { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } if ($result <= 0) { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } // Call trigger - $result=$this->call_trigger('PAYMENT_VARIOUS_CREATE', $user); + $result = $this->call_trigger('PAYMENT_VARIOUS_CREATE', $user); if ($result < 0) $error++; // End call triggers } else $error++; - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -477,7 +477,7 @@ class PaymentVarious extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -494,7 +494,7 @@ class PaymentVarious extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { @@ -542,27 +542,27 @@ class PaymentVarious extends CommonObject } elseif ($mode == 2) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } elseif ($mode == 4) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); - elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - elseif ($status==2 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + if ($status == 0 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status == 1 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status == 2 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } } @@ -581,34 +581,34 @@ class PaymentVarious extends CommonObject global $db, $conf, $langs, $hookmanager; global $langs; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; - $label=''.$langs->trans("ShowVariousPayment").''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("ShowVariousPayment").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('myobjectdao')); @@ -617,22 +617,22 @@ class PaymentVarious extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); global $action; $hookmanager->initHooks(array('variouspayment')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -648,8 +648,8 @@ class PaymentVarious extends CommonObject public function info($id) { $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; - $sql.= ' WHERE v.rowid = '.$id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; + $sql .= ' WHERE v.rowid = '.$id; dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 022e1ceea5a..9fd2207f3ec 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -67,7 +67,7 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); @@ -97,7 +97,7 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output . '/' . $object->ref; + $upload_dir = $conf->bank->dir_output.'/'.$object->ref; // Onglets $head = bank_prepare_head($object); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index ccf677fa2b8..347353be84f 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -257,7 +257,7 @@ else $show1 = $px1->show(); $px1 = null; - $graph_datas =null; + $graph_datas = null; $datas = null; $datamin = null; $dataall = null; @@ -395,7 +395,7 @@ else $show2 = $px2->show(); $px2 = null; - $graph_datas =null; + $graph_datas = null; $datas = null; $datamin = null; $dataall = null; @@ -509,7 +509,7 @@ else $show3 = $px3->show(); $px3 = null; - $graph_datas =null; + $graph_datas = null; $datas = null; $datamin = null; $dataall = null; diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php index 0ed5b4ff003..abab3b4ff9c 100644 --- a/htdocs/compta/bank/info.php +++ b/htdocs/compta/bank/info.php @@ -43,7 +43,7 @@ $object->fetch($id); $object->info($id); -$h=0; +$h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id; $head[$h][1] = $langs->trans("Card"); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index d98a37594b0..515759547a6 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -35,27 +35,27 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other')); -if (! empty($conf->adherent->enabled)) $langs->load("members"); -if (! empty($conf->don->enabled)) $langs->load("donations"); -if (! empty($conf->loan->enabled)) $langs->load("loan"); -if (! empty($conf->salaries->enabled)) $langs->load("salaries"); +if (!empty($conf->adherent->enabled)) $langs->load("members"); +if (!empty($conf->don->enabled)) $langs->load("donations"); +if (!empty($conf->loan->enabled)) $langs->load("loan"); +if (!empty($conf->salaries->enabled)) $langs->load("salaries"); $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$rowid=GETPOST("rowid", 'int'); -$orig_account=GETPOST("orig_account"); -$backtopage=GETPOST('backtopage', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$rowid = GETPOST("rowid", 'int'); +$orig_account = GETPOST("orig_account"); +$backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); -if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden(); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); +if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) accessforbidden(); /* @@ -92,10 +92,10 @@ if ($user->rights->banque->consolidate && $action == 'donext') if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) { - $cat1=GETPOST("cat1", 'int'); + $cat1 = GETPOST("cat1", 'int'); if (!empty($rowid) && !empty($cat1)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$cat1; - if (! $db->query($sql)) + if (!$db->query($sql)) { dol_print_error($db); } @@ -108,7 +108,7 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban if ($user->rights->banque->modifier && $action == "update") { - $error=0; + $error = 0; $acline = new AccountLine($db); $acline->fetch($rowid); @@ -117,7 +117,7 @@ if ($user->rights->banque->modifier && $action == "update") $acsource->fetch($id); $actarget = new Account($db); - if (GETPOST('accountid', 'int') > 0 && ! $acline->rappro && ! $acline->getVentilExportCompta()) // We ask to change bank account + if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) // We ask to change bank account { $actarget->fetch(GETPOST('accountid', 'int')); } @@ -132,52 +132,52 @@ if ($user->rights->banque->modifier && $action == "update") $error++; } - if (! $error) + if (!$error) { $db->begin(); $amount = price2num($_POST['amount']); $dateop = dol_mktime(12, 0, 0, $_POST["dateomonth"], $_POST["dateoday"], $_POST["dateoyear"]); - $dateval= dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $dateval = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET "; + $sql .= " SET "; // Always opened - if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',"; - if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',"; - if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',"; - if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',"; + if (isset($_POST['value'])) $sql .= " fk_type='".$db->escape($_POST['value'])."',"; + if (isset($_POST['num_chq'])) $sql .= " num_chq='".$db->escape($_POST["num_chq"])."',"; + if (isset($_POST['banque'])) $sql .= " banque='".$db->escape($_POST["banque"])."',"; + if (isset($_POST['emetteur'])) $sql .= " emetteur='".$db->escape($_POST["emetteur"])."',"; // Blocked when conciliated - if (! $acline->rappro) + if (!$acline->rappro) { - if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',"; - if (isset($_POST['amount'])) $sql.=" amount='".$amount."',"; - if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',"; - if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',"; + if (isset($_POST['label'])) $sql .= " label='".$db->escape($_POST["label"])."',"; + if (isset($_POST['amount'])) $sql .= " amount='".$amount."',"; + if (isset($_POST['dateomonth'])) $sql .= " dateo = '".$db->idate($dateop)."',"; + if (isset($_POST['datevmonth'])) $sql .= " datev = '".$db->idate($dateval)."',"; } - $sql.= " fk_account = ".$actarget->id; - $sql.= " WHERE rowid = ".$acline->id; + $sql .= " fk_account = ".$actarget->id; + $sql .= " WHERE rowid = ".$acline->id; $result = $db->query($sql); - if (! $result) + if (!$result) { $error++; } - if (! $error) + if (!$error) { - $arrayofcategs=GETPOST('custcats', 'array'); + $arrayofcategs = GETPOST('custcats', 'array'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; dol_print_error($db); } if (count($arrayofcategs)) { - foreach($arrayofcategs as $val) + foreach ($arrayofcategs as $val) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; dol_print_error($db); @@ -187,7 +187,7 @@ if ($user->rights->banque->modifier && $action == "update") } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); @@ -203,8 +203,8 @@ if ($user->rights->banque->modifier && $action == "update") // Reconcile if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) { - $num_rel=trim($_POST["num_rel"]); - $rappro=$_POST['reconciled']?1:0; + $num_rel = trim($_POST["num_rel"]); + $rappro = $_POST['reconciled'] ? 1 : 0; // Check parameters if ($rappro && empty($num_rel)) @@ -213,15 +213,15 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == $error++; } - if (! $error) + if (!$error) { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null"); - if (empty($num_rel)) $sql.= ", rappro = 0"; - else $sql.=", rappro = ".$rappro; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " SET num_releve=".($num_rel ? "'".$num_rel."'" : "null"); + if (empty($num_rel)) $sql .= ", rappro = 0"; + else $sql .= ", rappro = ".$rappro; + $sql .= " WHERE rowid = ".$rowid; dol_syslog("line.php", LOG_DEBUG); $result = $db->query($sql); @@ -267,11 +267,11 @@ $tabs = array( $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,"; -$sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; -$sql.= " b.emetteur,b.banque"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= " WHERE rowid=".$rowid; -$sql.= " ORDER BY dateo ASC"; +$sql .= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; +$sql .= " b.emetteur,b.banque"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= " WHERE rowid=".$rowid; +$sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { @@ -282,14 +282,14 @@ if ($result) $total = $total + $objp->amount; - $acct=new Account($db); + $acct = new Account($db); $acct->fetch($objp->fk_account); $account = $acct->id; $bankline = new AccountLine($db); $bankline->fetch($rowid, $ref); - $links=$acct->get_url($rowid); + $links = $acct->get_url($rowid); $bankline->load_previous_next_ref('', 'rowid'); // Confirmations @@ -321,7 +321,7 @@ if ($result) // Bank account print ''; print ''; print ''; } @@ -532,13 +532,13 @@ if ($result) { print ''; } @@ -555,7 +555,7 @@ if ($result) if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { print ''; } else @@ -601,12 +601,12 @@ if ($result) print ""; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); // Bank line - print '"; @@ -647,12 +647,12 @@ if ($result) print ''; @@ -667,7 +667,7 @@ if ($result) if ($user->rights->banque->consolidate) { print ''; } else diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 82cdd4e826a..c737af4a89e 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -205,9 +205,9 @@ $paymentvatstatic = new TVA($db); $bankstatic = new Account($db); $banklinestatic = new AccountLine($db); $remisestatic = new RemiseCheque($db); -$paymentdonationstatic=new PaymentDonation($db); -$paymentloanstatic=new PaymentLoan($db); -$paymentvariousstatic=new PaymentVarious($db); +$paymentdonationstatic = new PaymentDonation($db); +$paymentloanstatic = new PaymentLoan($db); +$paymentvariousstatic = new PaymentVarious($db); // Must be before button action $param = ''; @@ -518,28 +518,28 @@ else print ''; $newline = 0; } - elseif ($links[$key]['type']=='payment_donation') + elseif ($links[$key]['type'] == 'payment_donation') { - $paymentdonationstatic->id=$links[$key]['url_id']; - $paymentdonationstatic->ref=$langs->trans("Payment"); + $paymentdonationstatic->id = $links[$key]['url_id']; + $paymentdonationstatic->ref = $langs->trans("Payment"); print ' '.$paymentdonationstatic->getNomUrl(1); $newline = 0; } - elseif ($links[$key]['type']=='payment_loan') + elseif ($links[$key]['type'] == 'payment_loan') { - $paymentloanstatic->id=$links[$key]['url_id']; - $paymentloanstatic->ref=$langs->trans("Payment"); + $paymentloanstatic->id = $links[$key]['url_id']; + $paymentloanstatic->ref = $langs->trans("Payment"); print ' '.$paymentloanstatic->getNomUrl(1); $newline = 0; } - elseif ($links[$key]['type']=='payment_various') + elseif ($links[$key]['type'] == 'payment_various') { - $paymentvariousstatic->id=$links[$key]['url_id']; - $paymentvariousstatic->ref=$langs->trans("Payment"); + $paymentvariousstatic->id = $links[$key]['url_id']; + $paymentvariousstatic->ref = $langs->trans("Payment"); print ' '.$paymentvariousstatic->getNomUrl(1); $newline = 0; } - elseif ($links[$key]['type']=='banktransfert') { + elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) { diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 611d2fc42b0..cb6073f1109 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "categories", "multicurrency")); -if (! $user->rights->banque->transfer) +if (!$user->rights->banque->transfer) accessforbidden(); $action = GETPOST('action', 'alpha'); @@ -51,46 +51,46 @@ if ($action == 'add') $dateo = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $label = GETPOST('label', 'alpha'); - $amount= GETPOST('amount', 'alpha'); - $amountto= GETPOST('amountto', 'alpha'); + $amount = GETPOST('amount', 'alpha'); + $amountto = GETPOST('amountto', 'alpha'); - if (! $label) + if (!$label) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors'); } - if (! $amount) + if (!$amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); } - if (! GETPOST('account_from', 'int')) + if (!GETPOST('account_from', 'int')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), null, 'errors'); } - if (! GETPOST('account_to', 'int')) + if (!GETPOST('account_to', 'int')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferTo")), null, 'errors'); } - if (! $error) + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountfrom=new Account($db); + $accountfrom = new Account($db); $accountfrom->fetch(GETPOST('account_from', 'int')); - $accountto=new Account($db); + $accountto = new Account($db); $accountto->fetch(GETPOST('account_to', 'int')); if ($accountto->currency_code == $accountfrom->currency_code) { - $amountto=$amount; + $amountto = $amount; } else { - if (! $amountto) + if (!$amountto) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors'); @@ -101,31 +101,31 @@ if ($action == 'add') { $db->begin(); - $bank_line_id_from=0; - $bank_line_id_to=0; - $result=0; + $bank_line_id_from = 0; + $bank_line_id_to = 0; + $result = 0; // By default, electronic transfert from bank to bank - $typefrom='PRE'; - $typeto='VIR'; + $typefrom = 'PRE'; + $typeto = 'VIR'; if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { // This is transfer of change - $typefrom='LIQ'; - $typeto='LIQ'; + $typefrom = 'LIQ'; + $typeto = 'LIQ'; } - if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user); - if (! ($bank_line_id_from > 0)) $error++; - if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user); - if (! ($bank_line_id_to > 0)) $error++; + if (!$error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1 * price2num($amount), '', '', $user); + if (!($bank_line_id_from > 0)) $error++; + if (!$error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user); + if (!($bank_line_id_to > 0)) $error++; - if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); - if (! ($result > 0)) $error++; - if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); - if (! ($result > 0)) $error++; + if (!$error) $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!($result > 0)) $error++; + if (!$error) $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!($result > 0)) $error++; - if (! $error) + if (!$error) { $mesgs = $langs->trans("TransferFromToDone", ''.$accountfrom->label."", ''.$accountto->label."", $amount, $langs->transnoentities("Currency".$conf->currency)); setEventMessages($mesgs, null, 'mesgs'); @@ -214,17 +214,17 @@ print ' '; -$form=new Form($db); +$form = new Form($db); -$account_from=''; -$account_to=''; -$label=''; -$amount=''; +$account_from = ''; +$account_to = ''; +$label = ''; +$amount = ''; if ($error) { - $account_from = GETPOST('account_from', 'int'); - $account_to = GETPOST('account_to', 'int'); + $account_from = GETPOST('account_from', 'int'); + $account_to = GETPOST('account_to', 'int'); $label = GETPOST('label', 'alpha'); $amount = GETPOST('amount', 'alpha'); } @@ -246,17 +246,17 @@ print ''; print ''; -$var=false; +$var = false; print '"; print "\n"; print "\n"; print ''; print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 6573207a117..ccd6b24c6b9 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -40,37 +40,37 @@ if (!empty($conf->projet->enabled)) $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy", "categories")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); -$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; -$label = GETPOST("label", "alpha"); -$sens = GETPOST("sens", "int"); -$amount = price2num(GETPOST("amount", "alpha")); -$paymenttype = GETPOST("paymenttype", "int"); -$accountancy_code = GETPOST("accountancy_code", "alpha"); -$subledger_account = GETPOST("subledger_account", "alpha"); -$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); +$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; +$label = GETPOST("label", "alpha"); +$sens = GETPOST("sens", "int"); +$amount = price2num(GETPOST("amount", "alpha")); +$paymenttype = GETPOST("paymenttype", "int"); +$accountancy_code = GETPOST("accountancy_code", "alpha"); +$subledger_account = GETPOST("subledger_account", "alpha"); +$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', '', '', ''); $object = new PaymentVarious($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('variouscard','globalcard')); +$hookmanager->initHooks(array('variouscard', 'globalcard')); /** * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -429,44 +429,44 @@ if ($id) { $alreadyaccounted = $object->getVentilExportCompta(); - $head=various_payment_prepare_head($object); + $head = various_payment_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto); - $morehtmlref='
'; + $morehtmlref = '
'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->banque->modifier) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(1); + $morehtmlref .= $proj->getNomUrl(1); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; - $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref .= '
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index f0f584ca99b..05a7d28c8c8 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -30,12 +30,12 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', '', '', ''); /* @@ -53,40 +53,40 @@ $head = various_payment_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("VariousPayment"), -1, $object->picto); -$morehtmlref='
'; +$morehtmlref = '
'; // Project -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' : '; + $morehtmlref .= $langs->trans('Project').' : '; if ($user->rights->banque->modifier && 0) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(1); + $morehtmlref .= $proj->getNomUrl(1); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } -$morehtmlref.='
'; -$linkback = ''.$langs->trans("BackToList").''; +$morehtmlref .= '
'; +$linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index a6f68b31330..70a26d231e1 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -184,7 +184,7 @@ elseif ($action == "add") $action = "view"; } } - if ($contextpage == 'takepos'){ + if ($contextpage == 'takepos') { print " '; + $out .= ''; } else { - $out.= ''; + $out .= ''; } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 40bfe965c60..65051b3c05b 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_activity extends ModeleBoxes { - public $boxcode="activity"; - public $boximg="object_bill"; - public $boxlabel='BoxGlobalActivity'; + public $boxcode = "activity"; + public $boximg = "object_bill"; + public $boxlabel = 'BoxGlobalActivity'; public $depends = array("facture"); /** @@ -60,11 +60,11 @@ class box_activity extends ModeleBoxes $this->db = $db; // FIXME: Pb into some status - $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) + $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) - $this->hidden = ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire) - || (! empty($conf->commande->enabled) && $user->rights->commande->lire) - || (! empty($conf->propal->enabled) && $user->rights->propale->lire) + $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire) + || (!empty($conf->commande->enabled) && $user->rights->commande->lire) + || (!empty($conf->propal->enabled) && $user->rights->propale->lire) ); } @@ -84,11 +84,11 @@ class box_activity extends ModeleBoxes $totalnb = 0; $line = 0; $cachetime = 3600; - $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; + $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache'; $now = dol_now(); - $nbofperiod=3; + $nbofperiod = 3; - if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION; + if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION; $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); $this->info_box_head = array( 'text' => $textHead, @@ -96,14 +96,14 @@ class box_activity extends ModeleBoxes ); // compute the year limit to show - $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); + $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m"); // list the summary of the propals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($this->db); + $propalstatic = new Propal($this->db); $cachedir = DOL_DATA_ROOT.'/propale/temp'; $filename = '/boxactivity-propal'.$fileid; @@ -112,29 +112,29 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE p.entity IN (".getEntity('propal').")"; - $sql.= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; - $sql.= " AND p.date_cloture IS NULL"; // just unclosed - $sql.= " GROUP BY p.fk_statut"; - $sql.= " ORDER BY p.fk_statut DESC"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; + $sql .= " AND p.date_cloture IS NULL"; // just unclosed + $sql .= " GROUP BY p.fk_statut"; + $sql .= " ORDER BY p.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -147,9 +147,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) + if (!empty($data)) { - $j=0; + $j = 0; while ($j < count($data)) { $this->info_box_contents[$line][0] = array( @@ -188,9 +188,9 @@ class box_activity extends ModeleBoxes } // list the summary of the orders - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $commandestatic=new Commande($this->db); + $commandestatic = new Commande($this->db); $langs->load("orders"); @@ -201,26 +201,26 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE c.entity = ".$conf->entity; - $sql.= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; - $sql.= " GROUP BY c.fk_statut"; - $sql.= " ORDER BY c.fk_statut DESC"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; + $sql .= " GROUP BY c.fk_statut"; + $sql .= " ORDER BY c.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -231,8 +231,8 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) { - $j=0; + if (!empty($data)) { + $j = 0; while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', @@ -271,10 +271,10 @@ class box_activity extends ModeleBoxes // list the summary of the bills - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($this->db); + $facturestatic = new Facture($this->db); // part 1 $cachedir = DOL_DATA_ROOT.'/facture/temp'; @@ -285,26 +285,26 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; + $sql .= " GROUP BY f.fk_statut"; + $sql .= " ORDER BY f.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -315,10 +315,10 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) { - $j=0; + if (!empty($data)) { + $j = 0; while ($j < count($data)) { - $billurl="search_status=2&paye=1&year=".$data[$j]->annee; + $billurl = "search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), @@ -353,7 +353,7 @@ class box_activity extends ModeleBoxes $line++; $j++; } - if (count($data)==0) + if (count($data) == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), @@ -369,22 +369,22 @@ class box_activity extends ModeleBoxes $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; + $sql .= " GROUP BY f.fk_statut"; + $sql .= " ORDER BY f.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -395,12 +395,12 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) { - $alreadypaid=-1; + if (!empty($data)) { + $alreadypaid = -1; - $j=0; + $j = 0; while ($j < count($data)) { - $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; + $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), @@ -431,7 +431,7 @@ class box_activity extends ModeleBoxes $line++; $j++; } - if (count($data)==0) { + if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 05d4e1d3ac0..7c8c110db88 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays extends ModeleBoxes { - public $boxcode="birthdays"; - public $boximg="object_user"; - public $boxlabel="BoxTitleUserBirthdaysOfMonth"; + public $boxcode = "birthdays"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; public $depends = array("user"); /** @@ -60,7 +60,7 @@ class box_birthdays extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->user->user->lire && empty($user->socid)); + $this->hidden = !($user->rights->user->user->lire && empty($user->socid)); } /** @@ -74,24 +74,24 @@ class box_birthdays extends ModeleBoxes global $user, $langs; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic=new User($this->db); + $userstatic = new User($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); if ($user->rights->user->user->lire) { - $tmparray=dol_getdate(dol_now(), true); + $tmparray = dol_getdate(dol_now(), true); $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.entity IN (".getEntity('user').")"; - $sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); - $sql.= " ORDER BY u.birth ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.entity IN (".getEntity('user').")"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); + $sql .= " ORDER BY u.birth ASC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -107,7 +107,7 @@ class box_birthdays extends ModeleBoxes $userstatic->firstname = $objp->firstname; $userstatic->lastname = $objp->lastname; $userstatic->email = $objp->email; - $dateb=$this->db->jdate($objp->birth); + $dateb = $this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -118,7 +118,7 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day") . ' - ' . $age . ' ' . $langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( @@ -129,7 +129,7 @@ class box_birthdays extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"','text'=>$langs->trans("None")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index e48271c4d84..96fc97f2e37 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays_members extends ModeleBoxes { - public $boxcode="birthdays_members"; - public $boximg="object_user"; - public $boxlabel="BoxTitleMemberNextBirthdays"; + public $boxcode = "birthdays_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMemberNextBirthdays"; public $depends = array("adherent"); /** @@ -60,7 +60,7 @@ class box_birthdays_members extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->adherent->lire && empty($user->socid)); + $this->hidden = !($user->rights->adherent->lire && empty($user->socid)); } /** @@ -74,25 +74,25 @@ class box_birthdays_members extends ModeleBoxes global $user, $langs; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($this->db); + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { - $tmparray=dol_getdate(dol_now(), true); + $tmparray = dol_getdate(dol_now(), true); $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as u"; - $sql.= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql.= " AND u.statut = 1"; - $sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); - $sql.= " ORDER BY u.birth ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as u"; + $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); + $sql .= " ORDER BY u.birth ASC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -108,7 +108,7 @@ class box_birthdays_members extends ModeleBoxes $memberstatic->firstname = $objp->firstname; $memberstatic->lastname = $objp->lastname; $memberstatic->email = $objp->email; - $dateb=$this->db->jdate($objp->birth); + $dateb = $this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -119,7 +119,7 @@ class box_birthdays_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day") . ' - ' . $age . ' ' . $langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( @@ -130,7 +130,7 @@ class box_birthdays_members extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"','text'=>$langs->trans("None")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index 44102f0aab1..57c5ce2e2e2 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_boms extends ModeleBoxes { - public $boxcode="lastboms"; - public $boximg="object_bom"; - public $boxlabel="BoxTitleLatestModifiedBoms"; + public $boxcode = "lastboms"; + public $boximg = "object_bom"; + public $boxlabel = "BoxTitleLatestModifiedBoms"; public $depends = array("bom"); /** @@ -60,7 +60,7 @@ class box_boms extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->bom->read); + $this->hidden = !($user->rights->bom->read); } /** @@ -87,18 +87,18 @@ class box_boms extends ModeleBoxes if ($user->rights->bom->read) { $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; - $sql.= ", c.rowid"; - $sql.= ", c.date_creation"; - $sql.= ", c.tms"; - $sql.= ", c.ref"; - $sql.= ", c.status"; - $sql.= ", c.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ", ".MAIN_DB_PREFIX."bom_bom as c"; - $sql.= " WHERE c.fk_product = p.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.tms DESC, c.ref DESC"; - $sql.= " ".$this->db->plimit($max, 0); + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + $sql .= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -108,7 +108,7 @@ class box_boms extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $bomstatic->id = $objp->rowid; $bomstatic->ref = $objp->ref; @@ -131,11 +131,11 @@ class box_boms extends ModeleBoxes 'asis' => 1, ); - if (! empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), 'asis' => 1, ); } @@ -153,7 +153,7 @@ class box_boms extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedOrders")); $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 10b9c52acb0..37a25c8084d 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - public $boxcode="lastcustomerorders"; - public $boximg="object_order"; - public $boxlabel="BoxLastCustomerOrders"; + public $boxcode = "lastcustomerorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLastCustomerOrders"; public $depends = array("commande"); /** @@ -60,7 +60,7 @@ class box_commandes extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->commande->lire); + $this->hidden = !($user->rights->commande->lire); } /** @@ -83,35 +83,35 @@ class box_commandes extends ModeleBoxes $societestatic = new Societe($this->db); $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); if ($user->rights->commande->lire) { $sql = "SELECT s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.logo, s.email"; - $sql.= ", c.ref, c.tms"; - $sql.= ", c.rowid"; - $sql.= ", c.date_commande"; - $sql.= ", c.ref_client"; - $sql.= ", c.fk_statut"; - $sql.= ", c.fk_user_valid"; - $sql.= ", c.facture"; - $sql.= ", c.total_ht"; - $sql.= ", c.tva as total_tva"; - $sql.= ", c.total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", c.ref, c.tms"; + $sql .= ", c.rowid"; + $sql .= ", c.date_commande"; + $sql .= ", c.ref_client"; + $sql .= ", c.fk_statut"; + $sql .= ", c.fk_user_valid"; + $sql .= ", c.facture"; + $sql .= ", c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -121,8 +121,8 @@ class box_commandes extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $date=$this->db->jdate($objp->date_commande); - $datem=$this->db->jdate($objp->tms); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); $commandestatic->id = $objp->rowid; $commandestatic->ref = $objp->ref; $commandestatic->ref_client = $objp->ref_client; @@ -152,11 +152,11 @@ class box_commandes extends ModeleBoxes 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), 'asis' => 1, ); } @@ -174,7 +174,7 @@ class box_commandes extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedOrders")); $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 00f5722076c..b3f23817712 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,10 +33,10 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - public $boxcode="currentaccounts"; - public $boximg="object_bill"; - public $boxlabel="BoxCurrentAccounts"; - public $depends = array("banque"); // Box active if module banque active + public $boxcode = "currentaccounts"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active /** * @var DoliDB Database handler. @@ -63,10 +63,10 @@ class box_comptes extends ModeleBoxes $this->db = $db; // disable module for such cases - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (! in_array('banque', $listofmodulesforexternal) && ! empty($user->socid)) $this->enabled=0; // disabled for external users + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('banque', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0; // disabled for external users - $this->hidden = ! ($user->rights->banque->lire); + $this->hidden = !($user->rights->banque->lire); } /** @@ -79,25 +79,25 @@ class box_comptes extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); if ($user->rights->banque->lire) { $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; - $sql.= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; - $sql.= ", b.domiciliation, b.proprio, b.owner_address"; - $sql.= ", b.account_number, b.currency_code"; - $sql.= ", b.min_allowed, b.min_desired, comment"; - $sql.= ', b.fk_accountancy_journal'; - $sql.= ', aj.code as accountancy_journal'; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; - $sql.= " WHERE b.entity = ".$conf->entity; - $sql.= " AND clos = 0"; + $sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; + $sql .= ", b.domiciliation, b.proprio, b.owner_address"; + $sql .= ", b.account_number, b.currency_code"; + $sql .= ", b.min_allowed, b.min_desired, comment"; + $sql .= ', b.fk_accountancy_journal'; + $sql .= ', aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= " AND clos = 0"; //$sql.= " AND courant = 1"; - $sql.= " ORDER BY label"; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY label"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -118,7 +118,7 @@ class box_comptes extends ModeleBoxes $account_static->account_number = $objp->account_number; $account_static->currency_code = $objp->currency_code; $account_static->accountancy_journal = $objp->accountancy_journal; - $solde=$account_static->solde(0); + $solde = $account_static->solde(0); $solde_total[$objp->currency_code] += $solde; diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 36a4f5416f9..75fbc207134 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,10 +31,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - public $boxcode="lastcontracts"; - public $boximg="object_contract"; - public $boxlabel="BoxLastContracts"; - public $depends = array("contrat"); // conf->contrat->enabled + public $boxcode = "lastcontracts"; + public $boximg = "object_contract"; + public $boxlabel = "BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled /** * @var DoliDB Database handler. @@ -59,7 +59,7 @@ class box_contracts extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->contrat->lire); + $this->hidden = !($user->rights->contrat->lire); } /** @@ -72,7 +72,7 @@ class box_contracts extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; @@ -80,27 +80,27 @@ class box_contracts extends ModeleBoxes if ($user->rights->contrat->lire) { - $contractstatic=new Contrat($this->db); - $thirdpartytmp=new Societe($this->db); + $contractstatic = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql.= ", c.ref_customer, c.ref_supplier"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC "; - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $now=dol_now(); + $now = dol_now(); $line = 0; @@ -110,17 +110,17 @@ class box_contracts extends ModeleBoxes { $objp = $this->db->fetch_object($resql); - $datec=$this->db->jdate($objp->datec); - $dateterm=$this->db->jdate($objp->fin_validite); - $dateclose=$this->db->jdate($objp->date_cloture); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; - $contractstatic->statut=$objp->fk_statut; - $contractstatic->id=$objp->rowid; - $contractstatic->ref=$objp->ref; + $contractstatic->statut = $objp->fk_statut; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; $contractstatic->ref_customer = $objp->ref_customer; $contractstatic->ref_supplier = $objp->ref_supplier; - $result=$contractstatic->fetch_lines(); + $result = $contractstatic->fetch_lines(); $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; @@ -162,7 +162,7 @@ class box_contracts extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center opacitymedium"', 'text'=>$langs->trans("NoRecordedContracts"), diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index e0ac847c6f0..93ac43d6c22 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,9 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - public $boxcode="lastrssinfos"; - public $boximg="object_rss"; - public $boxlabel="BoxLastRssInfos"; + public $boxcode = "lastrssinfos"; + public $boximg = "object_rss"; + public $boxlabel = "BoxLastRssInfos"; public $depends = array("externalrss"); /** @@ -44,7 +44,7 @@ class box_external_rss extends ModeleBoxes */ public $db; - public $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) public $info_box_head = array(); public $info_box_contents = array(); @@ -58,8 +58,8 @@ class box_external_rss extends ModeleBoxes */ public function __construct($db, $param) { - $this->db=$db; - $this->paramdef=$param; + $this->db = $db; + $this->paramdef = $param; } /** @@ -74,93 +74,93 @@ class box_external_rss extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; // On recupere numero de param de la boite preg_match('/^([0-9]+) /', $this->paramdef, $reg); - $site=$reg[1]; + $site = $reg[1]; // Create dir nor required // documents/externalrss is created by module activation // documents/externalrss/tmp is created by rssparser - $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; - $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; + $keyforparamurl = "EXTERNAL_RSS_URLRSS_".$site; + $keyforparamtitle = "EXTERNAL_RSS_TITLE_".$site; // Get RSS feed - $url=$conf->global->$keyforparamurl; + $url = $conf->global->$keyforparamurl; - $rssparser=new RssParser($this->db); + $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); // INFO on channel - $description=$rssparser->getDescription(); - $link=$rssparser->getLink(); + $description = $rssparser->getDescription(); + $link = $rssparser->getLink(); - $title=$langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); - if ($result < 0 || ! empty($rssparser->error)) + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + if ($result < 0 || !empty($rssparser->error)) { // Show warning - $title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext"):$langs->trans("Unknown")))); - $this->info_box_head = array('text' => $title,'limit' => 0); + $title .= " ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")))); + $this->info_box_head = array('text' => $title, 'limit' => 0); } else { $this->info_box_head = array( 'text' => $title, 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext"):$langs->trans("Unknown")), + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), 'subpicto'=>'globe', 'target'=>'_blank', ); } // INFO on items - $items=$rssparser->getItems(); + $items = $rssparser->getItems(); //print '
'.print_r($items,true).'
'; - $nbitems=count($items); - for($line = 0; $line < $max && $line < $nbitems; $line++) + $nbitems = count($items); + for ($line = 0; $line < $max && $line < $nbitems; $line++) { $item = $items[$line]; // Feed common fields - $href = $item['link']; + $href = $item['link']; $title = urldecode($item['title']); - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') // If RSS { - if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; - if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; + if (!$date && isset($item['pubdate'])) $date = $item['pubdate']; + if (!$date && isset($item['dc']['date'])) $date = $item['dc']['date']; //$item['dc']['language'] //$item['dc']['publisher'] } if ($rssparser->getFormat() == 'atom') // If Atom { - if (! $date && isset($item['issued'])) $date=$item['issued']; - if (! $date && isset($item['modified'])) $date=$item['modified']; + if (!$date && isset($item['issued'])) $date = $item['issued']; + if (!$date && isset($item['modified'])) $date = $item['modified']; //$item['issued'] //$item['modified'] //$item['atom_content'] } - if (is_numeric($date)) $date=dol_print_date($date, "dayhour"); + if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); $isutf8 = utf8_check($title); - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); - $title=preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 - $title=preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"]="$title"; + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut + $this->info_box_contents["$href"] = "$title"; $tooltip = $title; - $description = ! empty($item['description'])?$item['description']:''; + $description = !empty($item['description']) ? $item['description'] : ''; $isutf8 = utf8_check($description); - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $description=utf8_encode($description); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description=utf8_decode($description); - $description=preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); - $description=preg_replace("/^\s+/", "", $description); - $description=str_replace("\r\n", "", $description); - $tooltip.= '
'.$description; + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); + $description = preg_replace("/^\s+/", "", $description); + $description = str_replace("\r\n", "", $description); + $tooltip .= '
'.$description; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 65724f5fa4b..ebaff31268d 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - public $boxcode="lastcustomerbills"; - public $boximg="object_bill"; - public $boxlabel="BoxLastCustomerBills"; + public $boxcode = "lastcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastCustomerBills"; public $depends = array("facture"); /** @@ -58,7 +58,7 @@ class box_factures extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** @@ -71,7 +71,7 @@ class box_factures extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -81,7 +81,7 @@ class box_factures extends ModeleBoxes $langs->load("bills"); - $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills", $max); + $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); $this->info_box_head = array( 'text' => $text, 'limit'=> dol_strlen($text) @@ -89,29 +89,29 @@ class box_factures extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT f.rowid as facid"; - $sql.= ", f.ref, f.type, f.total as total_ht"; - $sql.= ", f.tva as total_tva"; - $sql.= ", f.total_ttc"; - $sql.= ", f.datef as df"; - $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; - $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; - $sql.= ", f.date_lim_reglement as datelimite"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= ", f.ref, f.type, f.total as total_ht"; + $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ttc"; + $sql .= ", f.datef as df"; + $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $now=dol_now(); + $now = dol_now(); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; @@ -179,7 +179,7 @@ class box_factures extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 9eb836fe1e2..30f3cd503c2 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,10 +31,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - public $boxcode="lastsupplierbills"; - public $boximg="object_bill"; - public $boxlabel="BoxLastSupplierBills"; - public $depends = array("facture","fournisseur"); + public $boxcode = "lastsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastSupplierBills"; + public $depends = array("facture", "fournisseur"); /** * @var DoliDB Database handler. @@ -59,7 +59,7 @@ class box_factures_fourn extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** @@ -72,7 +72,7 @@ class box_factures_fourn extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; @@ -81,32 +81,32 @@ class box_factures_fourn extends ModeleBoxes $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array( - 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills", $max) + 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) ); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_fournisseur, s.email,"; - $sql.= " s.logo,"; - $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; - $sql.= " f.total_ht,"; - $sql.= " f.total_tva,"; - $sql.= " f.total_ttc,"; - $sql.= " f.paye, f.fk_statut,"; - $sql.= ' f.datef as df,'; - $sql.= ' f.datec as datec,'; - $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; + $sql .= " f.total_ht,"; + $sql .= " f.total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut,"; + $sql .= ' f.datef as df,'; + $sql .= ' f.datec as datec,'; + $sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -114,13 +114,13 @@ class box_factures_fourn extends ModeleBoxes $num = $this->db->num_rows($result); $line = 0; - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { $objp = $this->db->fetch_object($result); - $datelimite=$this->db->jdate($objp->datelimite); - $date=$this->db->jdate($objp->df); - $datem=$this->db->jdate($objp->tms); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; @@ -141,7 +141,7 @@ class box_factures_fourn extends ModeleBoxes $late = ''; if ($facturestatic->hasDelay()) { - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } $this->info_box_contents[$line][] = array( @@ -154,7 +154,7 @@ class box_factures_fourn extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150"', 'text' => $objp->ref_supplier, - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, ); @@ -176,7 +176,7 @@ class box_factures_fourn extends ModeleBoxes $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); - $alreadypaid=$fac->getSommePaiement(); + $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), @@ -185,7 +185,7 @@ class box_factures_fourn extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoModifiedSupplierBills"), diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index b1b108931b1..c2b5e7c705e 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -33,7 +33,7 @@ class box_factures_fourn_imp extends ModeleBoxes public $boxcode = "oldestunpaidsupplierbills"; public $boximg = "object_bill"; public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture","fournisseur"); + public $depends = array("facture", "fournisseur"); /** * @var DoliDB Database handler. @@ -58,7 +58,7 @@ class box_factures_fourn_imp extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** @@ -71,35 +71,35 @@ class box_factures_fourn_imp extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $facturestatic=new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp=new Fournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; - $sql.= " f.datef as df,"; - $sql.= " f.total_ht as total_ht,"; - $sql.= " f.tva as total_tva,"; - $sql.= " f.total_ttc,"; - $sql.= " f.paye, f.fk_statut, f.type"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ",".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.paye=0"; - $sql.= " AND fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " ORDER BY datelimite DESC, f.ref_supplier DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; + $sql .= " f.datef as df,"; + $sql .= " f.total_ht as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut, f.type"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.paye=0"; + $sql .= " AND fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY datelimite DESC, f.ref_supplier DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -114,9 +114,9 @@ class box_factures_fourn_imp extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datelimite=$this->db->jdate($objp->datelimite); - $date=$this->db->jdate($objp->df); - $datem=$this->db->jdate($objp->tms); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; @@ -130,12 +130,12 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; - $late=''; + $late = ''; if ($facturestatic->hasDelay()) { - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } - $tooltip = $langs->trans('SupplierInvoice') . ': ' . ($objp->ref?$objp->ref:$objp->facid) . '
' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier; + $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall"', @@ -162,7 +162,7 @@ class box_factures_fourn_imp extends ModeleBoxes $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); - $alreadypaid=$fac->getSommePaiement(); + $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), @@ -171,7 +171,7 @@ class box_factures_fourn_imp extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoUnpaidSupplierBills"), diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index a81b0cf3b86..e289c83d541 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,10 +31,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - public $boxcode="ficheinter"; - public $boximg="object_intervention"; - public $boxlabel="BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode = "ficheinter"; + public $boximg = "object_intervention"; + public $boxlabel = "BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** * @var DoliDB Database handler. @@ -59,7 +59,7 @@ class box_ficheinter extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->ficheinter->lire); + $this->hidden = !($user->rights->ficheinter->lire); } /** @@ -72,37 +72,37 @@ class box_ficheinter extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $ficheinterstatic=new Fichinter($this->db); + $ficheinterstatic = new Fichinter($this->db); $companystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); - if (! empty($user->rights->ficheinter->lire)) + if (!empty($user->rights->ficheinter->lire)) { $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,"; - $sql.= " f.datec,"; - $sql.= " f.date_valid as datev,"; - $sql.= " f.tms as datem,"; - $sql.= " s.nom as name, s.rowid as socid, s.client, s.email as semail"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; - $sql.= " WHERE f.fk_soc = s.rowid "; - $sql.= " AND f.entity = ".$conf->entity; - if (! $user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " ORDER BY f.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " f.datec,"; + $sql .= " f.date_valid as datev,"; + $sql .= " f.tms as datem,"; + $sql .= " s.nom as name, s.rowid as socid, s.client, s.email as semail"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; + $sql .= " WHERE f.fk_soc = s.rowid "; + $sql .= " AND f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY f.tms DESC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this).'::loadBox', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $now=dol_now(); + $now = dol_now(); $i = 0; @@ -111,9 +111,9 @@ class box_ficheinter extends ModeleBoxes $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); - $ficheinterstatic->statut=$objp->fk_statut; - $ficheinterstatic->id=$objp->rowid; - $ficheinterstatic->ref=$objp->ref; + $ficheinterstatic->statut = $objp->fk_statut; + $ficheinterstatic->id = $objp->rowid; + $ficheinterstatic->ref = $objp->ref; $companystatic->id = $objp->socid; $companystatic->name = $objp->name; @@ -145,7 +145,7 @@ class box_ficheinter extends ModeleBoxes $i++; } - if ($num==0) $this->info_box_contents[$i][] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedInterventions")); + if ($num == 0) $this->info_box_contents[$i][] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInterventions")); $this->db->free($resql); } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 242f26e5d60..2b2d8418e47 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - public $boxcode="lastmembers"; - public $boximg="object_user"; - public $boxlabel="BoxLastMembers"; + public $boxcode = "lastmembers"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembers"; public $depends = array("adherent"); /** @@ -62,10 +62,10 @@ class box_members extends ModeleBoxes $this->db = $db; // disable module for such cases - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (! in_array('adherent', $listofmodulesforexternal) && ! empty($user->socid)) $this->enabled=0; // disabled for external users + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0; // disabled for external users - $this->hidden = ! ($user->rights->adherent->lire); + $this->hidden = !($user->rights->adherent->lire); } /** @@ -79,23 +79,23 @@ class box_members extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($this->db); + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); if ($user->rights->adherent->lire) { $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; - $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; - $sql.= " t.subscription"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.entity IN (".getEntity('member').")"; - $sql.= " AND a.fk_adherent_type = t.rowid"; - $sql.= " ORDER BY a.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql .= " t.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE a.entity IN (".getEntity('member').")"; + $sql .= " AND a.fk_adherent_type = t.rowid"; + $sql .= " ORDER BY a.tms DESC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -106,21 +106,21 @@ class box_members extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datec=$this->db->jdate($objp->datec); - $datem=$this->db->jdate($objp->tms); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); - $memberstatic->lastname=$objp->lastname; - $memberstatic->firstname=$objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; $memberstatic->ref = $objp->rowid; $memberstatic->company = $objp->company; - if (! empty($objp->fk_soc)) { + if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; $memberstatic->fetch_thirdparty(); - $memberstatic->name=$memberstatic->thirdparty->name; + $memberstatic->name = $memberstatic->thirdparty->name; } else { - $memberstatic->name=$objp->company; + $memberstatic->name = $objp->company; } $this->info_box_contents[$line][] = array( @@ -148,7 +148,7 @@ class box_members extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers"), diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 949f63776f6..9b863aa2d5a 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_mos extends ModeleBoxes { - public $boxcode="lastmos"; - public $boximg="object_mrp"; - public $boxlabel="BoxTitleLatestModifiedMos"; + public $boxcode = "lastmos"; + public $boximg = "object_mrp"; + public $boxlabel = "BoxTitleLatestModifiedMos"; public $depends = array("mrp"); /** @@ -60,7 +60,7 @@ class box_mos extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->bom->read); + $this->hidden = !($user->rights->bom->read); } /** @@ -87,18 +87,18 @@ class box_mos extends ModeleBoxes if ($user->rights->mrp->read) { $sql = "SELECT p.ref as product_ref"; - $sql.= ", c.rowid"; - $sql.= ", c.date_creation"; - $sql.= ", c.tms"; - $sql.= ", c.ref"; - $sql.= ", c.status"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; //$sql.= ", c.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ", ".MAIN_DB_PREFIX."mrp_mo as c"; - $sql.= " WHERE c.fk_product = p.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.tms DESC, c.ref DESC"; - $sql.= " ".$this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -108,7 +108,7 @@ class box_mos extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $mostatic->id = $objp->rowid; $mostatic->ref = $objp->ref; $mostatic->id = $objp->socid; @@ -127,11 +127,11 @@ class box_mos extends ModeleBoxes 'asis' => 1, ); - if (! empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), 'asis' => 1, ); } @@ -149,7 +149,7 @@ class box_mos extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedOrders")); $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 5cccd24ad6a..374e9ab1bae 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,9 +33,9 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - public $boxcode="lastproducts"; - public $boximg="object_product"; - public $boxlabel="BoxLastProducts"; + public $boxcode = "lastproducts"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProducts"; public $depends = array("produit"); /** @@ -59,11 +59,11 @@ class box_produits extends ModeleBoxes { global $conf, $user; - $this->db=$db; + $this->db = $db; - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode=isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } @@ -77,29 +77,29 @@ class box_produits extends ModeleBoxes { global $user, $langs, $conf, $hookmanager; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($this->db); + $productstatic = new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; - if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; + if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; + if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks if (is_object($hookmanager)) { - $parameters=array('boxproductlist'=>1); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array('boxproductlist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } - $sql.= $this->db->order('p.datec', 'DESC'); - $sql.= $this->db->plimit($max, 0); + $sql .= $this->db->order('p.datec', 'DESC'); + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -109,16 +109,16 @@ class box_produits extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sqld = "SELECT label"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld.= " WHERE fk_product=".$objp->rowid; - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; - $sqld.= " LIMIT 1"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->rowid; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); if ($resultd) @@ -147,8 +147,8 @@ class box_produits extends ModeleBoxes $price = ''; $price_base_type = ''; if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type=$langs->trans($objp->price_base_type); - $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); } else //Parse the dynamic price { @@ -158,14 +158,14 @@ class box_produits extends ModeleBoxes if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { - $price_base_type=$langs->trans("HT"); + $price_base_type = $langs->trans("HT"); } else { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); - $price_base_type=$langs->trans("TTC"); + $price_base_type = $langs->trans("TTC"); } - $price=price($price_result); + $price = price($price_result); } } $this->info_box_contents[$line][] = array( @@ -197,7 +197,7 @@ class box_produits extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProducts"), diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 3c674cd32c0..f4a433c013d 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,9 +35,9 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - public $boxcode="productsalertstock"; - public $boximg="object_product"; - public $boxlabel="BoxProductsAlertStock"; + public $boxcode = "productsalertstock"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductsAlertStock"; public $depends = array("produit"); /** @@ -59,13 +59,13 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf,$user; + global $conf, $user; $this->db = $db; - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode=isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } @@ -79,34 +79,34 @@ class box_produits_alerte_stock extends ModeleBoxes { global $user, $langs, $conf, $hookmanager; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($this->db); + $productstatic = new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,"; - $sql.= " SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; - if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; - if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + $sql .= " SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; + $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; + $sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; + if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; + if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks if (is_object($hookmanager)) { - $parameters=array('boxproductalertstocklist'=>1); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array('boxproductalertstocklist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } - $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; - $sql.= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; - $sql.= $this->db->order('p.seuil_stock_alerte', 'DESC'); - $sql.= $this->db->plimit($max, 0); + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; + $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + $sql .= $this->db->order('p.seuil_stock_alerte', 'DESC'); + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -116,18 +116,18 @@ class box_produits_alerte_stock extends ModeleBoxes $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $price = ''; $price_base_type = ''; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sqld = "SELECT label"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld.= " WHERE fk_product=".$objp->rowid; - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; - $sqld.= " LIMIT 1"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->rowid; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); if ($resultd) @@ -156,8 +156,8 @@ class box_produits_alerte_stock extends ModeleBoxes if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type=$langs->trans($objp->price_base_type); - $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); } else //Parse the dynamic price { @@ -167,14 +167,14 @@ class box_produits_alerte_stock extends ModeleBoxes if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { - $price_base_type=$langs->trans("HT"); + $price_base_type = $langs->trans("HT"); } else { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); - $price_base_type=$langs->trans("TTC"); + $price_base_type = $langs->trans("TTC"); } - $price=price($price_result); + $price = price($price_result); } } @@ -190,7 +190,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte, + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), ); @@ -208,7 +208,7 @@ class box_produits_alerte_stock extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoTooLowStockProducts"), diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 9fffc92963f..c99f07ff311 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -31,8 +31,8 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - public $boxcode="project"; - public $boximg="object_projectpub"; + public $boxcode = "project"; + public $boximg = "object_projectpub"; public $boxlabel; //var $depends = array("projet"); @@ -62,7 +62,7 @@ class box_project extends ModeleBoxes $this->db = $db; $this->boxlabel = "OpenedProjects"; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = !($user->rights->projet->lire); } /** @@ -75,11 +75,11 @@ class box_project extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; $totalMnt = 0; $totalnb = 0; - $totalnbTask=0; + $totalnbTask = 0; $textHead = $langs->trans("OpenedProjects"); $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); @@ -89,20 +89,20 @@ class box_project extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); - $socid=0; + $socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok - $sql.= " AND p.fk_statut = 1"; // Only open projects - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql .= " AND p.fk_statut = 1"; // Only open projects + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - $sql.= " ORDER BY p.datec DESC"; + $sql .= " ORDER BY p.datec DESC"; //$sql.= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -130,10 +130,10 @@ class box_project extends ModeleBoxes 'text' => $objp->title, ); - $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; - $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - $sql.=" AND p.rowid = ".$objp->rowid; + $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql .= " WHERE p.entity IN (".getEntity('project').')'; + $sql .= " AND p.rowid = ".$objp->rowid; $resultTask = $this->db->query($sql); if ($resultTask) { $objTask = $this->db->fetch_object($resultTask); @@ -141,10 +141,10 @@ class box_project extends ModeleBoxes 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), ); - if ($objTask->nb > 0) + if ($objTask->nb > 0) $this->info_box_contents[$i][] = array( 'td' => 'class="right"', - 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", + 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", ); else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 9d6a10b6225..54ed1c76051 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,9 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - public $boxcode="lastprospects"; - public $boximg="object_company"; - public $boxlabel="BoxLastProspects"; + public $boxcode = "lastprospects"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastProspects"; public $depends = array("societe"); /** @@ -63,9 +63,9 @@ class box_prospect extends ModeleBoxes $this->db = $db; // disable box for such cases - if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled = 0; // disabled by this option - $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); } /** @@ -78,29 +78,29 @@ class box_prospect extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; - $thirdpartystatic=new Client($this->db); + $thirdpartystatic = new Client($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.client, s.email"; - $sql.= ", s.code_fournisseur"; - $sql.= ", s.fournisseur"; - $sql.= ", s.logo"; - $sql.= ", s.fk_stcomm, s.datec, s.tms, s.status"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.client IN (2, 3)"; - $sql.= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " ORDER BY s.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= ", s.code_client"; + $sql .= ", s.client, s.email"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.fk_stcomm, s.datec, s.tms, s.status"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.client IN (2, 3)"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY s.tms DESC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $resql = $this->db->query($sql); @@ -112,8 +112,8 @@ class box_prospect extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($resql); - $datec=$this->db->jdate($objp->datec); - $datem=$this->db->jdate($objp->tms); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->email = $objp->email; @@ -147,7 +147,7 @@ class box_prospect extends ModeleBoxes $line++; } - if ($num==0) { + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProspects"), diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 5b40fc61436..f8e6dd22452 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,10 +32,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - public $boxcode="lastproductsincontract"; - public $boximg="object_product"; - public $boxlabel="BoxLastProductsInContract"; - public $depends = array("service","contrat"); + public $boxcode = "lastproductsincontract"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProductsInContract"; + public $depends = array("service", "contrat"); /** * @var DoliDB Database handler. @@ -60,7 +60,7 @@ class box_services_contracts extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); } /** @@ -73,7 +73,7 @@ class box_services_contracts extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; @@ -83,52 +83,52 @@ class box_services_contracts extends ModeleBoxes if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic=new Contrat($this->db); - $contractlinestatic=new ContratLigne($this->db); + $contractstatic = new Contrat($this->db); + $contractlinestatic = new ContratLigne($this->db); $thirdpartytmp = new Societe($this->db); $productstatic = new Product($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; - $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= ")"; - $sql.= " WHERE c.entity = ".$conf->entity; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= $this->db->order("c.tms", "DESC"); - $sql.= $this->db->plimit($max, 0); + $sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; + $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= ")"; + $sql .= " WHERE c.entity = ".$conf->entity; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= $this->db->order("c.tms", "DESC"); + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $now=dol_now(); + $now = dol_now(); $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->datem); + $datem = $this->db->jdate($objp->datem); - $contractlinestatic->id=$objp->cdid; - $contractlinestatic->fk_contrat=$objp->rowid; - $contractlinestatic->label=$objp->label; - $contractlinestatic->description=$objp->description; - $contractlinestatic->type=$objp->type; - $contractlinestatic->product_id=$objp->product_id; - $contractlinestatic->product_ref=$objp->product_ref; + $contractlinestatic->id = $objp->cdid; + $contractlinestatic->fk_contrat = $objp->rowid; + $contractlinestatic->label = $objp->label; + $contractlinestatic->description = $objp->description; + $contractlinestatic->type = $objp->type; + $contractlinestatic->product_id = $objp->product_id; + $contractlinestatic->product_ref = $objp->product_ref; - $contractstatic->statut=$objp->contract_status; - $contractstatic->id=$objp->rowid; - $contractstatic->ref=$objp->ref; - $contractstatic->ref_customer=$objp->ref_customer; - $contractstatic->ref_supplier=$objp->ref_supplier; + $contractstatic->statut = $objp->contract_status; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; @@ -141,13 +141,13 @@ class box_services_contracts extends ModeleBoxes $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on + if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on { $sqld = "SELECT label"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld.= " WHERE fk_product=".$objp->product_id; - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; - $sqld.= " LIMIT 1"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->product_id; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); if ($resultd) @@ -160,11 +160,11 @@ class box_services_contracts extends ModeleBoxes // Label if ($objp->product_id > 0) { - $productstatic->id=$objp->product_id; - $productstatic->type=$objp->ptype; - $productstatic->ref=$objp->product_ref; - $productstatic->entity=$objp->pentity; - $productstatic->label=$objp->plabel; + $productstatic->id = $objp->product_id; + $productstatic->type = $objp->ptype; + $productstatic->ref = $objp->product_ref; + $productstatic->entity = $objp->pentity; + $productstatic->label = $objp->plabel; $productstatic->status = $objp->tosell; $productstatic->status_buy = $objp->tobuy; @@ -179,13 +179,13 @@ class box_services_contracts extends ModeleBoxes $description = $objp->description; // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; - $description = ''; // Already added into main visible desc + $description = ''; // Already added into main visible desc } - $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { @@ -223,7 +223,7 @@ class box_services_contracts extends ModeleBoxes $i++; } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("NoContractedProducts")); + if ($num == 0) $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoContractedProducts")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 881e17f73ec..c019062313c 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -33,7 +33,7 @@ class box_supplier_orders extends ModeleBoxes public $boxcode = "latestsupplierorders"; public $boximg = "object_order"; - public $boxlabel="BoxLatestSupplierOrders"; + public $boxlabel = "BoxLatestSupplierOrders"; public $depends = array("fournisseur"); /** @@ -58,7 +58,7 @@ class box_supplier_orders extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->rights->fournisseur->commande->lire); } /** @@ -75,32 +75,32 @@ class box_supplier_orders extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic=new CommandeFournisseur($this->db); + $supplierorderstatic = new CommandeFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); if ($user->rights->fournisseur->commande->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_client, s.code_fournisseur,"; - $sql.= " s.logo, s.email,"; - $sql.= " c.rowid, c.ref, c.tms, c.date_commande,"; - $sql.= " c.total_ht,"; - $sql.= " c.tva as total_tva,"; - $sql.= " c.total_ttc,"; - $sql.= " c.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " s.code_client, s.code_fournisseur,"; + $sql .= " s.logo, s.email,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -110,8 +110,8 @@ class box_supplier_orders extends ModeleBoxes $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $date=$this->db->jdate($objp->date_commande); - $datem=$this->db->jdate($objp->tms); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 416dc7f2f2a..f70f5bef450 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -33,7 +33,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes public $boxcode = "supplierordersawaitingreception"; public $boximg = "object_order"; - public $boxlabel="BoxLatestSupplierOrdersAwaitingReception"; + public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; public $depends = array("fournisseur"); /** @@ -58,7 +58,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->rights->fournisseur->commande->lire); } /** @@ -75,7 +75,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic=new CommandeFournisseur($this->db); + $supplierorderstatic = new CommandeFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); @@ -84,25 +84,25 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_client, s.code_fournisseur, s.email,"; - $sql.= " s.logo,"; - $sql.= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; - $sql.= " c.total_ht,"; - $sql.= " c.tva as total_tva,"; - $sql.= " c.total_ttc,"; - $sql.= " c.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql .= " s.code_client, s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql.= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -112,9 +112,9 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $date=$this->db->jdate($objp->date_commande); - $date_livraison=$this->db->jdate($objp->date_livraison); - $datem=$this->db->jdate($objp->tms); + $date = $this->db->jdate($objp->date_commande); + $date_livraison = $this->db->jdate($objp->date_livraison); + $datem = $this->db->jdate($objp->tms); $supplierorderstatic->date_livraison = $date_livraison; $supplierorderstatic->statut = $objp->fk_statut; @@ -153,7 +153,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $delayIcon.' '. dol_print_date($date_livraison, 'day').'', + 'text' => $delayIcon.' '.dol_print_date($date_livraison, 'day').'', 'asis' => 1 ); diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index f8888c71a4b..f9a974ae1c5 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -127,7 +127,7 @@ class box_task extends ModeleBoxes $boxcontent .= ''; $boxcontent .= ''."\n"; $boxcontent .= ''."\n"; - if (! empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { $boxcontent .= '' ; - exit ; + $rpl = array('\\' => '\\\\', '"' => '\\"'); + echo 'window.parent.OnUploadCompleted('.$errorNumber.',"'.strtr($fileUrl, $rpl).'","'.strtr($fileName, $rpl).'", "'.strtr($customMsg, $rpl).'");'; + echo ''; + exit; } @@ -403,9 +403,9 @@ function SendCKEditorResults($callback, $sFileUrl, $customMsg = '') { echo ''; } diff --git a/htdocs/core/filemanagerdol/connectors/php/upload.php b/htdocs/core/filemanagerdol/connectors/php/upload.php index 9364f3bd540..b1f97d10395 100644 --- a/htdocs/core/filemanagerdol/connectors/php/upload.php +++ b/htdocs/core/filemanagerdol/connectors/php/upload.php @@ -41,22 +41,22 @@ function SendError($number, $text) // Check if this uploader has been enabled. -if ( !$Config['Enabled'] ) +if (!$Config['Enabled']) SendUploadResults('1', '', '', 'This file uploader is disabled. Please check the "filemanagerdol/connectors/php/config.php" file'); -$sCommand = 'QuickUpload' ; +$sCommand = 'QuickUpload'; // The file type (from the QueryString, by default 'File'). -$sType = isset($_GET['Type']) ? $_GET['Type'] : 'File' ; +$sType = isset($_GET['Type']) ? $_GET['Type'] : 'File'; -$sCurrentFolder = "/" ; +$sCurrentFolder = "/"; // Is enabled the upload? -if (! IsAllowedCommand($sCommand)) - SendUploadResults('1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed'); +if (!IsAllowedCommand($sCommand)) + SendUploadResults('1', '', '', 'The ""'.$sCommand.'"" command isn\'t allowed'); // Check if it is an allowed type. -if (! IsAllowedType($sType)) +if (!IsAllowedType($sType)) SendUploadResults(1, '', '', 'Invalid type specified'); diff --git a/htdocs/core/filemanagerdol/connectors/php/util.php b/htdocs/core/filemanagerdol/connectors/php/util.php index 9f80b96b2fd..3ea4baf8c87 100644 --- a/htdocs/core/filemanagerdol/connectors/php/util.php +++ b/htdocs/core/filemanagerdol/connectors/php/util.php @@ -31,7 +31,7 @@ */ function RemoveFromStart($sourceString, $charToRemove) { - $sPattern = '|^' . $charToRemove . '+|' ; + $sPattern = '|^'.$charToRemove.'+|'; return preg_replace($sPattern, '', $sourceString); } @@ -44,7 +44,7 @@ function RemoveFromStart($sourceString, $charToRemove) */ function RemoveFromEnd($sourceString, $charToRemove) { - $sPattern = '|' . $charToRemove . '+$|' ; + $sPattern = '|'.$charToRemove.'+$|'; return preg_replace($sPattern, '', $sourceString); } @@ -67,7 +67,7 @@ function FindBadUtf8($string) '|(.{1}))'; while (preg_match('/'.$regex.'/S', $string, $matches)) { - if ( isset($matches[2])) { + if (isset($matches[2])) { return true; } $string = substr($string, strlen($matches[0])); @@ -84,9 +84,9 @@ function FindBadUtf8($string) */ function ConvertToXmlAttribute($value) { - if ( defined('PHP_OS') ) + if (defined('PHP_OS')) { - $os = PHP_OS ; + $os = PHP_OS; } else { @@ -112,9 +112,9 @@ function ConvertToXmlAttribute($value) */ function IsHtmlExtension($ext, $formExtensions) { - if (!$formExtensions || !is_array($formExtensions) ) + if (!$formExtensions || !is_array($formExtensions)) { - return false ; + return false; } $lcaseHtmlExtensions = array(); foreach ($formExtensions as $key => $val) @@ -137,9 +137,9 @@ function DetectHtml($filePath) $fp = @fopen($filePath, 'rb'); //open_basedir restriction, see #1906 - if ( $fp === false || !flock($fp, LOCK_SH) ) + if ($fp === false || !flock($fp, LOCK_SH)) { - return -1 ; + return -1; } $chunk = fread($fp, 1024); @@ -150,47 +150,47 @@ function DetectHtml($filePath) if (!$chunk) { - return false ; + return false; } $chunk = trim($chunk); - if ( preg_match("/setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php $langs->load("main"); -$right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); -$left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); +$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); /* * View */ -$title=$langs->trans("Menu"); +$title = $langs->trans("Menu"); // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests -$head=''."\n"; -$arrayofjs=array(); -$arrayofcss=array(); +$head = ''."\n"; +$arrayofjs = array(); +$arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); print ''."\n"; @@ -176,34 +176,34 @@ $(document).ready(function(){ if (empty($user->socid)) // If internal user or not defined { - $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED); + $conf->standard_menu = (empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENU_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED); } else // If external user { - $conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?(empty($conf->global->MAIN_MENUFRONT_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENUFRONT_STANDARD):$conf->global->MAIN_MENUFRONT_STANDARD_FORCED); + $conf->standard_menu = (empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENUFRONT_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENUFRONT_STANDARD) : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED); } // Load the menu manager (only if not already done) -$file_menu=$conf->standard_menu; -if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php -if (! class_exists('MenuManager')) +$file_menu = $conf->standard_menu; +if (GETPOST('menu')) $file_menu = GETPOST('menu'); // example: menu=eldy_menu.php +if (!class_exists('MenuManager')) { - $menufound=0; - $dirmenus=array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); - foreach($dirmenus as $dirmenu) + $menufound = 0; + $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); + foreach ($dirmenus as $dirmenu) { - $menufound=dol_include_once($dirmenu."standard/".$file_menu); + $menufound = dol_include_once($dirmenu."standard/".$file_menu); if ($menufound) break; } - if (! $menufound) // If failed to include, we try with standard + if (!$menufound) // If failed to include, we try with standard { dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); - $file_menu='eldy_menu.php'; + $file_menu = 'eldy_menu.php'; include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } -$menumanager = new MenuManager($db, empty($user->socid)?0:1); -$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries +$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); +$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries //var_dump($menumanager);exit; $menumanager->showmenu('jmobile'); diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index c40dd571190..40596596b97 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions (included if option use_javascript activated) */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -62,7 +62,7 @@ if (empty($conf->dol_no_mouse_hover)) print ' jQuery(".classfortooltiponclicktext").dialog( { closeOnEscape: true, classes: { "ui-dialog": "highlight" }, - maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth']-20, 320) : 700).', + maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth'] - 20, 320) : 700).', modal: true, autoOpen: false }).css("z-index: 5000"); jQuery(".classfortooltiponclick").click(function () { @@ -79,7 +79,7 @@ print "});\n"; // Wrapper to manage dropdown -if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) +if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) { print "\n/* JS CODE TO ENABLE dropdown (hamburger, linkto, ...) */\n"; print ' @@ -151,7 +151,7 @@ if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) // Wrapper to manage document_preview if ($conf->browser->layout != 'phone') { - print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header + print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header print ' jQuery(document).ready(function () { jQuery(".documentpreview").click(function () { diff --git a/htdocs/core/js/lib_gravatar.js.php b/htdocs/core/js/lib_gravatar.js.php index 9e1a85b57c4..59a1e5fddb5 100644 --- a/htdocs/core/js/lib_gravatar.js.php +++ b/htdocs/core/js/lib_gravatar.js.php @@ -24,14 +24,14 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Not disabled cause need to do translations -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index a35fee85d0a..1efa4c88771 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -24,13 +24,13 @@ * JQuery (providing object $) and JQuery-UI (providing $datepicker) libraries must be loaded before this file. */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -45,7 +45,7 @@ else header('Cache-Control: no-cache'); // Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8) -$tradMonths=array( +$tradMonths = array( dol_escape_js($langs->transnoentitiesnoconv("Month01")), dol_escape_js($langs->transnoentitiesnoconv("Month02")), dol_escape_js($langs->transnoentitiesnoconv("Month03")), @@ -60,7 +60,7 @@ dol_escape_js($langs->transnoentitiesnoconv("Month11")), dol_escape_js($langs->transnoentitiesnoconv("Month12")) ); -$tradMonthsShort=array( +$tradMonthsShort = array( $langs->trans("MonthShort01"), $langs->trans("MonthShort02"), $langs->trans("MonthShort03"), @@ -75,7 +75,7 @@ $langs->trans("MonthShort11"), $langs->trans("MonthShort12") ); -$tradDays=array( +$tradDays = array( $langs->trans("Sunday"), $langs->trans("Monday"), $langs->trans("Tuesday"), @@ -85,7 +85,7 @@ $langs->trans("Friday"), $langs->trans("Saturday") ); -$tradDaysShort=array( +$tradDaysShort = array( $langs->trans("ShortSunday"), $langs->trans("ShortMonday"), $langs->trans("ShortTuesday"), @@ -95,7 +95,7 @@ $langs->trans("ShortFriday"), $langs->trans("ShortSaturday") ); -$tradDaysMin=array( +$tradDaysMin = array( $langs->trans("SundayMin"), $langs->trans("MondayMin"), $langs->trans("TuesdayMin"), @@ -139,8 +139,8 @@ jQuery(function($){ dayNamesMin: tradDaysMin, weekHeader: 'trans("Week"); ?>', dateFormat: 'trans("FormatDateShortJQuery"); ?>', /* Note dd/mm/yy means year on 4 digit in jquery format */ - firstDay: global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'); ?>, - isRTL: trans("DIRECTION")=='rtl'?'true':'false'); ?>, + firstDay: global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'); ?>, + isRTL: trans("DIRECTION") == 'rtl' ? 'true' : 'false'); ?>, showMonthAfterYear: false, /* TODO add specific to country */ yearSuffix: '' /* TODO add specific to country */ }; @@ -1060,8 +1060,8 @@ function price2numjs(amount) { if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { $thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); } - if ($thousand == 'Space') $thousand=' '; - print "var dec='" . dol_escape_js($dec) . "'; var thousand='" . dol_escape_js($thousand) . "';\n"; // Set var in javascript + if ($thousand == 'Space') $thousand = ' '; + print "var dec='".dol_escape_js($dec)."'; var thousand='".dol_escape_js($thousand)."';\n"; // Set var in javascript ?> var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN); ?>; @@ -1093,7 +1093,7 @@ function price2numjs(amount) { global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { +if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { ?> // Defined properties for JNotify $(document).ready(function() { diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index e78161d167d..3e4f838fe33 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -29,15 +29,15 @@ if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); require_once '../../main.inc.php'; -if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/index.php' +if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/index.php' || preg_match('/getmenu_div\.php/', $_SERVER['HTTP_REFERER']))) { global $langs, $conf; top_httphead('text/javascript; charset=UTF-8'); - print 'var login = \'' . $_SESSION['dol_login'] . '\';' . "\n"; - print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined + print 'var login = \''.$_SESSION['dol_login'].'\';'."\n"; + print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined print 'var time_js_next_test = (Date.now() + time_auto_update);'."\n"; ?> @@ -74,7 +74,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H if (arr.length > 0) { var audio = null; global->AGENDA_REMINDER_BROWSER_SOUND)) { + if (!empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');'; } ?> diff --git a/htdocs/core/js/timepicker.js.php b/htdocs/core/js/timepicker.js.php index e47c06cfd91..158c755935f 100644 --- a/htdocs/core/js/timepicker.js.php +++ b/htdocs/core/js/timepicker.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions for timepicker */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -55,7 +55,7 @@ jQuery(function($){ timeFormat: 'HH:mm', amNames: ['AM', 'A'], pmNames: ['PM', 'P'], - isRTL: trans("DIRECTION")=='rtl'?'true':'false'); ?> + isRTL: trans("DIRECTION") == 'rtl' ? 'true' : 'false'); ?> }; $.timepicker.setDefaults($.timepicker.regional['defaultlang ?>']); }); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 0200fbc5b91..21682a4abe6 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -53,12 +53,12 @@ function accounting_prepare_head(AccountingAccount $object) global $langs, $conf; $h = 0; - $head = array (); + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; - $h ++; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -96,18 +96,18 @@ function length_accountg($account) if ($account < 0 || is_empty($account)) return ''; - if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account; + if (!is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account; $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT; - if (! is_empty($g)) { + if (!is_empty($g)) { // Clean parameters $i = strlen($account); if ($i >= 1) { - while ( $i < $g ) { + while ($i < $g) { $account .= '0'; - $i ++; + $i++; } return $account; @@ -131,18 +131,18 @@ function length_accounta($accounta) if ($accounta < 0 || is_empty($accounta)) return ''; - if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta; + if (!is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta; $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT; - if (! is_empty($a)) { + if (!is_empty($a)) { // Clean parameters $i = strlen($accounta); if ($i >= 1) { - while ( $i < $a ) { + while ($i < $a) { $accounta .= '0'; - $i ++; + $i++; } return $accounta; @@ -177,10 +177,10 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build print "\n\n\n"; - if(! is_empty($varlink)) $varlink = '?'.$varlink; + if (!is_empty($varlink)) $varlink = '?'.$varlink; - $head=array(); - $h=0; + $head = array(); + $h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("Journalization"); $head[$h][2] = 'journal'; @@ -190,7 +190,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build dol_fiche_head($head, 'journal'); - foreach($moreparam as $key => $value) + foreach ($moreparam as $key => $value) { print ''; } @@ -209,7 +209,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build { print ''; print ''; - if (! $variante) print ''; print ''; - if (! $periodlink) print ''; if ($conf->resource->enabled) { - include_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; - $formresource=new FormResource($db); + include_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; + $formresource = new FormResource($db); // Resource print ''; @@ -103,16 +103,16 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; } - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) + if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { print ''; print ''; } - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); print ''; print ''; } - if ($canedit && ! preg_match('/list/', $_SERVER["PHP_SELF"])) + if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) { // Status print ''; @@ -188,7 +188,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
'.$keyparam.''; - if ($keyparam == 'Path') $valtoshow=implode('; ', explode(';', trim($valtoshow))); - if ($keyparam == 'PATH') $valtoshow=implode('; ', explode(';', trim($valtoshow))); - if ($keyparam == '_SERVER["PATH"]') $valtoshow=implode('; ', explode(';', trim($valtoshow))); + if ($keyparam == 'Path') $valtoshow = implode('; ', explode(';', trim($valtoshow))); + if ($keyparam == 'PATH') $valtoshow = implode('; ', explode(';', trim($valtoshow))); + if ($keyparam == '_SERVER["PATH"]') $valtoshow = implode('; ', explode(';', trim($valtoshow))); print $valtoshow; print '
'.$keyparam.''; - $valtoshow=$keyvalue2; - if ($keyparam == 'disable_functions') $valtoshow=implode(', ', explode(',', trim($valtoshow))); + $valtoshow = $keyvalue2; + if ($keyparam == 'disable_functions') $valtoshow = implode(', ', explode(',', trim($valtoshow))); //print $keyparam; print $valtoshow; $i++; @@ -275,18 +275,18 @@ function getActivatedExtensions() $extensions = array(); $lastLine = ""; - foreach($configLines as $line) + foreach ($configLines as $line) { $line = trim($line); // ignore comment lines - if(substr($line, 0, 1) === ";") + if (substr($line, 0, 1) === ";") { continue; } // extension - if(substr($line, 0, 9) === "extension" && substr($line, 0, 10) !== "extension_") + if (substr($line, 0, 9) === "extension" && substr($line, 0, 10) !== "extension_") { $value = trim(end(explode("=", $line))); @@ -294,7 +294,7 @@ function getActivatedExtensions() } // zend_extension - if(substr($line, 0, 14) === "zend_extension") + if (substr($line, 0, 14) === "zend_extension") { $extensions[] = str_replace("[", "", str_replace("]", "", $lastLine)); } @@ -314,11 +314,11 @@ function getConfigFilePath() { $phparray = phpinfo_array(); - foreach($phparray as $value) + foreach ($phparray as $value) { - foreach($value as $keyparam => $keyvalue) + foreach ($value as $keyparam => $keyvalue) { - if(strtolower($keyparam) !== "loaded configuration file") + if (strtolower($keyparam) !== "loaded configuration file") { continue; } @@ -340,10 +340,10 @@ function getConfigFilePath() */ function getTableColumn($name, array $list) { - $name = strtolower($name); + $name = strtolower($name); $html = ""; - if(in_array($name, $list)) + if (in_array($name, $list)) { $html .= 'Ok'; } @@ -366,7 +366,7 @@ function getTableColumn($name, array $list) */ function getTableColumnFunction(array $functions) { - if(count($functions) < 1) + if (count($functions) < 1) { return "-"; - foreach($functions as $function) + foreach ($functions as $function) { $result = $result && function_exists($function); } - if($result) + if ($result) { $html .= 'Ok'; } @@ -411,14 +411,14 @@ function getResultColumn($name, array $activated, array $loaded, array $function $result = $result && in_array(strtolower($name), $activated); $result = $result && in_array(strtolower($name), $loaded); - foreach($functions as $function) + foreach ($functions as $function) { $result = $result && function_exists($function); } $html = ""; - $html .= $result ? $langs->trans("PHPSupport".$name) : $langs->trans("ErrorPHPDoesNotSupport".$name); - $html .= "
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; - print ''; + print ''; print '
'; print $langs->trans("NotAvailableWhenAjaxDisabled"); @@ -154,7 +154,7 @@ else else { print ''; - $listval=array( + $listval = array( '0'=>$langs->trans(""), '1'=>$langs->trans("Monthly"), '2'=>$langs->trans("Quarterly"), @@ -259,7 +259,7 @@ print "
\n"; print '
'; -print ''; +print ''; print '
'; print ''; @@ -267,7 +267,7 @@ print ''; -if (! empty($conf->accounting->enabled)) +if (!empty($conf->accounting->enabled)) { $langs->load("accountancy"); print '

'.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).''; diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index d7be1d058e6..a01996b31ac 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -23,8 +23,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('ticket', 'admin')); @@ -52,7 +52,7 @@ if (!$user->admin) { * Actions */ -include DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php'; +include DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; @@ -66,7 +66,7 @@ $help_url = "FR:Module_Ticket"; $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("TicketSetup"), $linkback, 'title_setup'); $head = ticketAdminPrepareHead(); @@ -80,7 +80,7 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action == 'create') { print "
"; print load_fiche_titre($langs->trans('NewAttribute')); - include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -106,7 +106,7 @@ if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 05546fdee5a..68bbd03162f 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -456,9 +456,9 @@ print "\n"; print $langs->trans("Compression").':   '; $i = 0; -foreach($compression as $key => $val) +foreach ($compression as $key => $val) { - if (! $val['function'] || function_exists($val['function'])) { + if (!$val['function'] || function_exists($val['function'])) { // Enabled export format $checked = ''; if ($key == 'gz') $checked = ' checked'; @@ -555,12 +555,12 @@ print $langs->trans("BackupDescX").'

'; print '
'; -print load_fiche_titre($title?$title:$langs->trans("BackupZipWizard")); +print load_fiche_titre($title ? $title : $langs->trans("BackupZipWizard")); print '
'; -$prefix='documents'; -$ext='zip'; -$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M"); +$prefix = 'documents'; +$ext = 'zip'; +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M"); print '
'; print '
'; @@ -573,12 +573,12 @@ print "\n"; print $langs->trans("Compression").':   '; $filecompression = $compression; unset($filecompression['none']); -$filecompression['zip']= array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip")); +$filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip")); $i = 0; -foreach($filecompression as $key => $val) +foreach ($filecompression as $key => $val) { - if (! $val['function'] || function_exists($val['function'])) // Enabled export format + if (!$val['function'] || function_exists($val['function'])) // Enabled export format { $checked = ''; if ($key == 'gz') $checked = ' checked'; @@ -609,8 +609,8 @@ print '
'; print '
'; print '
'; -$filearray=dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC), 1); -$result=$formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles")); +$filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles")); print '
'; print '
'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index c6c31fe7f45..e9885e82bfe 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -25,31 +25,31 @@ require '../../main.inc.php'; // Load translation files required by the page -$langs->loadLangs(array("other","admin")); +$langs->loadLangs(array("other", "admin")); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$radio_dump=GETPOST('radio_dump'); -$showpass=GETPOST('showpass'); +$radio_dump = GETPOST('radio_dump'); +$showpass = GETPOST('showpass'); /* * View */ -$label=$db::LABEL; -$type=$db->type; +$label = $db::LABEL; +$type = $db->type; -$help_url='EN:Restores|FR:Restaurations|ES:Restauraciones'; +$help_url = 'EN:Restores|FR:Restaurations|ES:Restauraciones'; llxHeader('', '', $help_url); ?> '; - $nbno=$nbtotal=0; + $nbno = $nbtotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"), '', 'products'); print '
'."\n"; - $sql ="SELECT count(rowid) as nb, fk_product_type, datec"; - $sql.=" FROM ".MAIN_DB_PREFIX."product"; - $sql.=" WHERE barcode IS NULL OR barcode = ''"; - $sql.=" GROUP BY fk_product_type, datec"; - $sql.=" ORDER BY datec"; - $resql=$db->query($sql); + $sql = "SELECT count(rowid) as nb, fk_product_type, datec"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE barcode IS NULL OR barcode = ''"; + $sql .= " GROUP BY fk_product_type, datec"; + $sql .= " ORDER BY datec"; + $resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); + $num = $db->num_rows($resql); - $i=0; - while($i < $num) + $i = 0; + while ($i < $num) { - $obj=$db->fetch_object($resql); - $nbno+=$obj->nb; + $obj = $db->fetch_object($resql); + $nbno += $obj->nb; $i++; } } else dol_print_error($db); - $sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product"; - $resql=$db->query($sql); + $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - $nbtotal=$obj->nb; + $obj = $db->fetch_object($resql); + $nbtotal = $obj->nb; } else dol_print_error($db); @@ -291,26 +291,26 @@ if ($conf->product->enabled || $conf->product->service) if (is_object($modBarCodeProduct)) { print $langs->trans("BarCodeNumberManager").": "; - $objproduct=new Product($db); - print ''.(isset($modBarCodeProduct->name)?$modBarCodeProduct->name:$modBarCodeProduct->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeProduct->getNextValue($objproduct).'
'; - $disabled=0; + $objproduct = new Product($db); + print ''.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeProduct->getNextValue($objproduct).'
'; + $disabled = 0; } else { - $disabled=1; - $titleno=$langs->trans("NoBarcodeNumberingTemplateDefined"); + $disabled = 1; + $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; } if (empty($nbno)) { - $disabled1=1; + $disabled1 = 1; } print '
'; //print ' '.$langs->trans("ResetBarcodeForAllRecords").'
'; - $moretags1=(($disabled||$disabled1)?' disabled title="'.dol_escape_htmltag($titleno).'"':''); + $moretags1 = (($disabled || $disabled1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); print ''; - $moretags2=(($nbno == $nbtotal)?' disabled':''); + $moretags2 = (($nbno == $nbtotal) ? ' disabled' : ''); print '   '; print ''; print '



'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 3bd7f0097b9..d753b3a66ea 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -33,29 +33,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "blockedlog", "bills")); -if ((! $user->admin && ! $user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden(); +if ((!$user->admin && !$user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden(); $action = GETPOST('action', 'alpha'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'blockedloglist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'blockedloglist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $search_showonlyerrors = GETPOST('search_showonlyerrors', 'int'); -if ($search_showonlyerrors < 0) $search_showonlyerrors=0; +if ($search_showonlyerrors < 0) $search_showonlyerrors = 0; -$search_fk_user=GETPOST('search_fk_user', 'intcomma'); +$search_fk_user = GETPOST('search_fk_user', 'intcomma'); $search_start = -1; -if (GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear')); +if (GETPOST('search_startyear') != '') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear')); $search_end = -1; -if (GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear')); +if (GETPOST('search_endyear') != '') $search_end = dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear')); $search_code = GETPOST('search_code', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -if (($search_start == -1 || empty($search_start)) && ! GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w'); +if (($search_start == -1 || empty($search_start)) && !GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -64,8 +64,8 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (empty($sortfield)) $sortfield='rowid'; -if (empty($sortorder)) $sortorder='DESC'; +if (empty($sortfield)) $sortfield = 'rowid'; +if (empty($sortorder)) $sortorder = 'DESC'; $block_static = new BlockedLog($db); @@ -78,7 +78,7 @@ $result = restrictedArea($user, 'blockedlog', 0, ''); */ // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $search_fk_user = ''; $search_start = -1; @@ -87,8 +87,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_ref = ''; $search_amount = ''; $search_showonlyerrors = 0; - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if ($action === 'downloadblockchain') { @@ -98,7 +98,7 @@ if ($action === 'downloadblockchain') { header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + header("Content-disposition: attachment; filename=\"".$auth->signature.".certif\""); echo $bc; @@ -106,26 +106,26 @@ if ($action === 'downloadblockchain') { } elseif (GETPOST('downloadcsv', 'alpha')) { $error = 0; - $previoushash=''; - $firstid=''; + $previoushash = ''; + $firstid = ''; - if (! $error) + if (!$error) { // Get ID of first line $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sql .= " WHERE entity = ".$conf->entity; if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0) { - $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):1); - $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):12); - $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; + $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1); + $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12); + $sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; } - $sql.= " ORDER BY rowid ASC"; // Required so we get the first one - $sql.= $db->plimit(1); + $sql .= " ORDER BY rowid ASC"; // Required so we get the first one + $sql .= $db->plimit(1); $res = $db->query($sql); - if($res) + if ($res) { // Make the first fetch to get first line $obj = $db->fetch_object($res); @@ -147,26 +147,26 @@ if ($action === 'downloadblockchain') { } } - if (! $error) + if (!$error) { // Now restart request with all data = no limit(1) in sql request $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sql .= " WHERE entity = ".$conf->entity; if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0) { - $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):1); - $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):12); - $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; + $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1); + $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12); + $sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; } - $sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature() + $sql .= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature() $res = $db->query($sql); - if($res) + if ($res) { header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport', 'int')>0 ? GETPOST('yeartoexport', 'int').(GETPOST('monthtoexport', 'int')>0?sprintf("%02d", GETPOST('monthtoexport', 'int')):'').'-':'').$previoushash. ".csv\""); + header("Content-disposition: attachment; filename=\"unalterable-log-archive-".$dolibarr_main_db_name."-".(GETPOST('yeartoexport', 'int') > 0 ? GETPOST('yeartoexport', 'int').(GETPOST('monthtoexport', 'int') > 0 ?sprintf("%02d", GETPOST('monthtoexport', 'int')) : '').'-' : '').$previoushash.".csv\""); print $langs->transnoentities('Id') .';'.$langs->transnoentities('Date') @@ -204,7 +204,7 @@ if ($action === 'downloadblockchain') { $block_static->signature = $obj->signature; $block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data); - $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it + $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it if ($checksignature) { @@ -219,9 +219,9 @@ if ($action === 'downloadblockchain') { $loweridinerror = $obj->rowid; } - if ($i==0) + if ($i == 0) { - $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote?' - '.$statusofrecordnote:''); + $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote ? ' - '.$statusofrecordnote : ''); } print $obj->rowid .';'.$obj->date_creation @@ -258,15 +258,15 @@ if ($action === 'downloadblockchain') { * View */ -$form=new Form($db); +$form = new Form($db); if (GETPOST('withtab', 'alpha')) { - $title=$langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'); + $title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'); } else { - $title=$langs->trans("BrowseBlockedLog"); + $title = $langs->trans("BrowseBlockedLog"); } llxHeader('', $langs->trans("BrowseBlockedLog")); @@ -274,7 +274,7 @@ llxHeader('', $langs->trans("BrowseBlockedLog")); $MAXLINES = 10000; $blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code); -if (! is_array($blocks)) +if (!is_array($blocks)) { if ($blocks == -2) { @@ -287,17 +287,17 @@ if (! is_array($blocks)) } } -$linkback=''; +$linkback = ''; if (GETPOST('withtab', 'alpha')) { - $linkback=''.$langs->trans("BackToModuleList").''; + $linkback = ''.$langs->trans("BackToModuleList").''; } print load_fiche_titre($title, $linkback); if (GETPOST('withtab', 'alpha')) { - $head=blockedlogadmin_prepare_head(); + $head = blockedlogadmin_prepare_head(); dol_fiche_head($head, 'fingerprints', '', -1); } @@ -305,19 +305,19 @@ print ''.$langs->trans("Fingerprint print '
'; -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -if ($search_fk_user > 0) $param.='&search_fk_user='.urlencode($search_fk_user); -if ($search_startyear > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear', 'int')); -if ($search_startmonth > 0) $param.='&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int')); -if ($search_startday > 0) $param.='&search_startday='.urlencode(GETPOST('search_startday', 'int')); -if ($search_endyear > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear', 'int')); -if ($search_endmonth > 0) $param.='&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int')); -if ($search_endday > 0) $param.='&search_endday='.urlencode(GETPOST('search_endday', 'int')); -if ($search_showonlyerrors > 0) $param.='&search_showonlyerrors='.urlencode($search_showonlyerrors); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); -if (GETPOST('withtab', 'alpha')) $param.='&withtab='.urlencode(GETPOST('withtab', 'alpha')); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); +if ($search_startyear > 0) $param .= '&search_startyear='.urlencode(GETPOST('search_startyear', 'int')); +if ($search_startmonth > 0) $param .= '&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int')); +if ($search_startday > 0) $param .= '&search_startday='.urlencode(GETPOST('search_startday', 'int')); +if ($search_endyear > 0) $param .= '&search_endyear='.urlencode(GETPOST('search_endyear', 'int')); +if ($search_endmonth > 0) $param .= '&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int')); +if ($search_endday > 0) $param .= '&search_endday='.urlencode(GETPOST('search_endday', 'int')); +if ($search_showonlyerrors > 0) $param .= '&search_showonlyerrors='.urlencode($search_showonlyerrors); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (GETPOST('withtab', 'alpha')) $param .= '&withtab='.urlencode(GETPOST('withtab', 'alpha')); // Add $param from extra fields //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -326,30 +326,30 @@ print '
'; print $langs->trans("RestrictYearToExport").': '; -$smonth=GETPOST('monthtoexport', 'int'); +$smonth = GETPOST('monthtoexport', 'int'); // Month -$retstring=''; -$retstring.=''; +$retstring .= ''; +for ($month = 1; $month <= 12; $month++) { - $retstring.='"; + $retstring .= '"; } -$retstring.=""; +$retstring .= ""; print $retstring; print ''; print ''; print ''; -if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').''; +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').''; print '

'; print ''; print '
'; -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table if ($optioncss != '') print ''; print ''; @@ -405,7 +405,7 @@ print '
'; -$array=array("1"=>$langs->trans("OnlyNonValid")); +$array = array("1"=>$langs->trans("OnlyNonValid")); print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1); print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error + if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4'); else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8'); @@ -520,13 +520,13 @@ if (is_array($blocks)) // Note print ''; - if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error + if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { if ($checkresult[$block->id]) print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo')); } - if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { - print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); + if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { + print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black')); } print ''; -print ''; +print ''; print '
'.($i+1).''.($i + 1).'qty_frozen?' checked="checked"':'')).'>'; +print 'qty_frozen ? ' checked="checked"' : '')).'>'; print 'disable_stock_change?' checked="checked"':'')).'">'; +print 'disable_stock_change ? ' checked="checked"' : '')).'">'; print ''; print ''; -$coldisplay+=$colspan; +$coldisplay += $colspan; print ''; print '
'; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index ce440dbaab6..b6197342136 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -34,7 +34,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) +if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; @@ -46,7 +46,7 @@ print "
  '.$langs->trans('Description').''.$form->textwithpicto($langs->trans( // Cost print ''.$langs->trans('CostPrice').''; $coldisplay++; -echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price +echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; @@ -108,10 +108,10 @@ $coldisplay++; echo price($line->total_cost); print ''; $coldisplay++; - if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { + if (($line->info_bits & 2) == 2 || !empty($disableedit)) { } else { print 'id.'#line_'.$line->id.'">'.img_edit().''; } diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index b2c7d227b38..bc0c0c37fc2 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -31,16 +31,16 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); if ($action == 'setvalue') { $showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha'); $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -59,7 +59,7 @@ if ($action == 'setvalue') llxHeader(); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BookmarkSetup"), $linkback, 'title_setup'); print $langs->trans("BookmarkDesc")."
\n"; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 699065520da..46e9ca315a5 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -60,7 +60,7 @@ function printDropdownBookmarksList() } $searchForm = ''."\n"; - $searchForm .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)?'onsubmit="return false"':'').'>'; + $searchForm .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? 'onsubmit="return false"' : '').'>'; $searchForm .= ''; @@ -106,9 +106,9 @@ function printDropdownBookmarksList() $searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">'; $searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...'; // Url to go on create new bookmark page - if (! empty($user->rights->bookmark->creer)) + if (!empty($user->rights->bookmark->creer)) { - $urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); + $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); $searchForm .= ''; } @@ -131,10 +131,10 @@ function printDropdownBookmarksList() $searchForm .= ''; // Generate the return string - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $html = $searchForm; - $html.=' + $html .= ' '; print '
'; + print ''; print ' '; print '
'.$langs->trans("Average").'
'.$langs->trans("Total").''.price($total).''.price($totalnb?price2num($total / $totalnb, 'MT'):0).'
'.price($totalnb ?price2num($total / $totalnb, 'MT') : 0).'
'.$langs->trans("Account").''; - if (! $objp->rappro && ! $bankline->getVentilExportCompta()) + if (!$objp->rappro && !$bankline->getVentilExportCompta()) { $form->select_comptes($acct->id, 'accountid', 0, '', 0); } @@ -337,12 +337,12 @@ if ($result) { print '
'.$langs->trans("Links").''; - foreach($links as $key=>$val) + foreach ($links as $key=>$val) { if ($key) print '
'; - if ($links[$key]['type']=='payment') { + if ($links[$key]['type'] == 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $paymenttmp=new Paiement($db); + $paymenttmp = new Paiement($db); $paymenttmp->fetch($links[$key]['url_id']); $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; /*print ''; @@ -351,9 +351,9 @@ if ($result) print '';*/ print $paymenttmp->getNomUrl(1); } - elseif ($links[$key]['type']=='payment_supplier') { + elseif ($links[$key]['type'] == 'payment_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; - $paymenttmp=new PaiementFourn($db); + $paymenttmp = new PaiementFourn($db); $paymenttmp->fetch($links[$key]['url_id']); $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; /*print ''; @@ -362,72 +362,72 @@ if ($result) print '';*/ print $paymenttmp->getNomUrl(1); } - elseif ($links[$key]['type']=='company') { - $societe=new Societe($db); + elseif ($links[$key]['type'] == 'company') { + $societe = new Societe($db); $societe->fetch($links[$key]['url_id']); print $societe->getNomUrl(1); } - elseif ($links[$key]['type']=='sc') { + elseif ($links[$key]['type'] == 'sc') { print ''; print img_object($langs->trans('ShowSocialContribution'), 'bill').' '; - print $langs->trans("SocialContribution").($links[$key]['label']?' - '.$links[$key]['label']:''); + print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); print ''; } - elseif ($links[$key]['type']=='payment_sc') { + elseif ($links[$key]['type'] == 'payment_sc') { print ''; print img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("SocialContributionPayment"); print ''; } - elseif ($links[$key]['type']=='payment_vat') { + elseif ($links[$key]['type'] == 'payment_vat') { print ''; print img_object($langs->trans('ShowVAT'), 'payment').' '; print $langs->trans("VATPayment"); print ''; } - elseif ($links[$key]['type']=='payment_salary') { + elseif ($links[$key]['type'] == 'payment_salary') { print ''; print img_object($langs->trans('ShowPaymentSalary'), 'payment').' '; print $langs->trans("SalaryPayment"); print ''; } - elseif ($links[$key]['type']=='payment_loan') { + elseif ($links[$key]['type'] == 'payment_loan') { print ''; print img_object($langs->trans('ShowLoanPayment'), 'payment').' '; print $langs->trans("PaymentLoan"); print ''; } - elseif ($links[$key]['type']=='loan') { + elseif ($links[$key]['type'] == 'loan') { print ''; print img_object($langs->trans('ShowLoan'), 'bill').' '; print $langs->trans("Loan"); print ''; } - elseif ($links[$key]['type']=='member') { + elseif ($links[$key]['type'] == 'member') { print ''; print img_object($langs->trans('ShowMember'), 'user').' '; print $links[$key]['label']; print ''; } - elseif ($links[$key]['type']=='payment_donation') { + elseif ($links[$key]['type'] == 'payment_donation') { print ''; print img_object($langs->trans('ShowDonation'), 'payment').' '; print $langs->trans("DonationPayment"); print ''; } - elseif ($links[$key]['type']=='banktransfert') { + elseif ($links[$key]['type'] == 'banktransfert') { print ''; print img_object($langs->trans('ShowTransaction'), 'payment').' '; print $langs->trans("TransactionOnTheOtherAccount"); print ''; } - elseif ($links[$key]['type']=='user') { + elseif ($links[$key]['type'] == 'user') { print ''; print img_object($langs->trans('ShowUser'), 'user').' '; print $langs->trans("User"); print ''; } - elseif ($links[$key]['type']=='payment_various') { + elseif ($links[$key]['type'] == 'payment_various') { print ''; print img_object($langs->trans('ShowVariousPayment'), 'payment').' '; print $langs->trans("VariousPayment"); @@ -458,7 +458,7 @@ if ($result) if ($objp->receiptid) { include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $receipt=new RemiseCheque($db); + $receipt = new RemiseCheque($db); $receipt->fetch($objp->receiptid); print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); } @@ -508,13 +508,13 @@ if ($result) { print '
'; print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro); - if (! $objp->rappro) + if (!$objp->rappro) { print '   '; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; } print ''; print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro); - if (! $objp->rappro) + if (!$objp->rappro) { print '   '; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; } print ''; - print 'rappro?' disabled':'').' value="'; + print 'rappro ? ' disabled' : '').' value="'; if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant @@ -589,7 +589,7 @@ if ($result) if ($user->rights->banque->modifier) { print ''; - print 'rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); + print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); print '
' . $form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0) . ''; + print '
'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); print "
'; if ($objp->rappro) { - print $langs->trans("AccountStatement").' rappro?' disabled':'').'>'; + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; print ''; } else { - print $langs->trans("AccountStatement").' rappro?' disabled':'').'>'; + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; } if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; print ''; - print 'rappro?' checked="checked"':'')).'">'; + print 'rappro ? ' checked="checked"' : '')).'">'; print ''.$langs->trans("TransferFrom").''.$langs->trans("TransferTo print '
'; -$form->select_comptes($account_from, 'account_from', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1); +$form->select_comptes($account_from, 'account_from', 0, '', 1, '', empty($conf->multicurrency->enabled) ? 0 : 1); print "\n"; -$form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1); +$form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->multicurrency->enabled) ? 0 : 1); print ""; -print $form->selectDate((! empty($dateo)?$dateo:''), '', '', '', '', 'add'); +print $form->selectDate((!empty($dateo) ? $dateo : ''), '', '', '', '', 'add'); print "
'.$langs->trans("CalculationMode").''; + if (!$variante) print ''; else print ''; print $calcmode; if ($variante) print ''.$variante; @@ -220,7 +220,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build // Ligne de la periode d'analyse du rapport print '
'.$langs->trans("ReportPeriod").''; + if (!$periodlink) print ''; else print ''; if ($period) print $period; if ($periodlink) print ''.$periodlink; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index e5d7422cf8a..f2833c98e62 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -54,17 +54,17 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $langs->load("companies"); - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); // Filters //print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
'; @@ -79,15 +79,15 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
'; print $langs->trans("ActionsToDoBy").'   '; print ''; - print $form->select_dolusers($filtert, 'search_filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").'   '; - print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); + print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or").' '.$langs->trans("ToUserOfGroup").'   '; + print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit); print '
'; print $langs->trans("Type"); print '  '; - $multiselect=0; - if (! empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" + $multiselect = 0; + if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" { - $multiselect=(!empty($conf->global->AGENDA_USE_EVENT_TYPE)); + $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } - print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect); + print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect); print '
'; @@ -122,20 +122,20 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
'; print $langs->trans("Project").'   '; print ''; - print $formproject->select_projects($socid?$socid:-1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); + print $formproject->select_projects($socid ? $socid : -1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); print '
'; print '
'; print '
'; - print ''; + print ''; print '
'; print '
'; @@ -196,7 +196,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if ($conf->browser->layout == 'phone') print '
'; else print ''; - print ''; // Close fichecenter + print ''; // Close fichecenter print '
'; //print ''; @@ -213,26 +213,26 @@ function show_array_actions_to_do($max = 5) { global $langs, $conf, $user, $db, $bc, $socid; - $now=dol_now(); + $now = dol_now(); include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; $sql = "SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent,"; - $sql.= " c.code, c.libelle as type_label,"; - $sql.= " s.nom as sname, s.rowid, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; - $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE a.entity = ".$conf->entity; - $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY a.datep DESC, a.id DESC"; - $sql.= $db->plimit($max, 0); + $sql .= " c.code, c.libelle as type_label,"; + $sql .= " s.nom as sname, s.rowid, s.client"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; + $sql .= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE a.entity = ".$conf->entity; + $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY a.datep DESC, a.id DESC"; + $sql .= $db->plimit($max, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -246,8 +246,8 @@ function show_array_actions_to_do($max = 5) $var = true; $i = 0; - $staticaction=new ActionComm($db); - $customerstatic=new Client($db); + $staticaction = new ActionComm($db); + $customerstatic = new Client($db); while ($i < $num) { @@ -256,9 +256,9 @@ function show_array_actions_to_do($max = 5) print ''; - $staticaction->type_code=$obj->code; - $staticaction->label=($obj->label?$obj->label:$obj->type_label); - $staticaction->id=$obj->id; + $staticaction->type_code = $obj->code; + $staticaction->label = ($obj->label ? $obj->label : $obj->type_label); + $staticaction->id = $obj->id; print ''.$staticaction->getNomUrl(1, 34).''; // print ''.dol_trunc($obj->label,22).''; @@ -266,23 +266,23 @@ function show_array_actions_to_do($max = 5) print ''; if ($obj->rowid > 0) { - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; + $customerstatic->id = $obj->rowid; + $customerstatic->name = $obj->sname; + $customerstatic->client = $obj->client; print $customerstatic->getNomUrl(1, '', 16); } print ''; - $datep=$db->jdate($obj->dp); - $datep2=$db->jdate($obj->dp2); + $datep = $db->jdate($obj->dp); + $datep2 = $db->jdate($obj->dp2); // Date print ''.dol_print_date($datep, 'day').' '; - $late=0; - if ($obj->percent == 0 && $datep && $datep < time()) $late=1; - if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && ! $datep2 && $datep && $datep < time()) $late=1; + $late = 0; + if ($obj->percent == 0 && $datep && $datep < time()) $late = 1; + if ($obj->percent == 0 && !$datep && $datep2 && $datep2 < time()) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && !$datep2 && $datep && $datep < time()) $late = 1; if ($late) print img_warning($langs->trans("Late")); print ""; @@ -314,23 +314,23 @@ function show_array_last_actions_done($max = 5) { global $langs, $conf, $user, $db, $bc, $socid; - $now=dol_now(); + $now = dol_now(); $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; - $sql.= " c.code, c.libelle,"; - $sql.= " s.rowid, s.nom as sname, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; - $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE a.entity = ".$conf->entity; - $sql.= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql .= " c.code, c.libelle,"; + $sql .= " s.rowid, s.nom as sname, s.client"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; + $sql .= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE a.entity = ".$conf->entity; + $sql .= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY a.datep2 DESC"; $sql .= $db->plimit($max, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -343,8 +343,8 @@ function show_array_last_actions_done($max = 5) $var = true; $i = 0; - $staticaction=new ActionComm($db); - $customerstatic=new Societe($db); + $staticaction = new ActionComm($db); + $customerstatic = new Societe($db); while ($i < $num) { @@ -353,9 +353,9 @@ function show_array_last_actions_done($max = 5) print ''; - $staticaction->type_code=$obj->code; - $staticaction->libelle=$obj->label; - $staticaction->id=$obj->id; + $staticaction->type_code = $obj->code; + $staticaction->libelle = $obj->label; + $staticaction->id = $obj->id; print ''.$staticaction->getNomUrl(1, 34).''; //print ''.dol_trunc($obj->label,24).''; @@ -363,9 +363,9 @@ function show_array_last_actions_done($max = 5) print ''; if ($obj->rowid > 0) { - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; + $customerstatic->id = $obj->rowid; + $customerstatic->name = $obj->sname; + $customerstatic->client = $obj->client; print $customerstatic->getNomUrl(1, '', 24); } print ''; @@ -467,13 +467,13 @@ function actions_prepare_head($object) if ($conf->resource->enabled) { include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; - $resource=new DolResource($db); + $resource = new DolResource($db); $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; $listofresourcelinked = $resource->getElementResources($object->element, $object->id); - $nbResources=(is_array($listofresourcelinked)?count($listofresourcelinked):0); + $nbResources = (is_array($listofresourcelinked) ?count($listofresourcelinked) : 0); $head[$h][1] = $langs->trans("Resources"); - if ($nbResources > 0) $head[$h][1].= ''.($nbResources).''; + if ($nbResources > 0) $head[$h][1] .= ''.($nbResources).''; $head[$h][2] = 'resources'; $h++; } @@ -481,12 +481,12 @@ function actions_prepare_head($object) // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->agenda->dir_output . "/" . $object->id; + $upload_dir = $conf->agenda->dir_output."/".$object->id; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -516,30 +516,30 @@ function calendars_prepare_head($param) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/list.php'.($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/list.php'.($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("ViewList"); $head[$h][2] = 'cardlist'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_month'.($param?'&'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_month'.($param ? '&'.$param : ''); $head[$h][1] = $langs->trans("ViewCal"); $head[$h][2] = 'cardmonth'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_week'.($param?'&'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_week'.($param ? '&'.$param : ''); $head[$h][1] = $langs->trans("ViewWeek"); $head[$h][2] = 'cardweek'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_day'.($param?'&'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_day'.($param ? '&'.$param : ''); $head[$h][1] = $langs->trans("ViewDay"); $head[$h][2] = 'cardday'; $h++; //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - if (! empty($conf->global->AGENDA_SHOW_PERTYPE)) + if (!empty($conf->global->AGENDA_SHOW_PERTYPE)) { - $head[$h][0] = DOL_URL_ROOT.'/comm/action/pertype.php'.($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/pertype.php'.($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("ViewPerType"); $head[$h][2] = 'cardpertype'; $h++; @@ -547,7 +547,7 @@ function calendars_prepare_head($param) $newparam = $param; $newparam = preg_replace('/&?search_filtert=\d+/', '', $newparam); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/peruser.php'.($newparam?'?'.$newparam:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/peruser.php'.($newparam ? '?'.$newparam : ''); $head[$h][1] = $langs->trans("ViewPerUser"); $head[$h][2] = 'cardperuser'; $h++; diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 5c6bac579f2..1b58784f6e8 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -35,7 +35,7 @@ function asset_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/setup.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/setup.php'; $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; @@ -50,12 +50,12 @@ function asset_admin_prepare_head() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin'); - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_type_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_type_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); $head[$h][2] = 'attributes_type'; $h++; @@ -80,7 +80,7 @@ function asset_prepare_head(Asset $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/asset/card.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/card.php'; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -97,25 +97,25 @@ function asset_prepare_head(Asset $object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->assets->dir_output . '/' . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->assets->dir_output.'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/asset/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/asset/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -135,7 +135,7 @@ function asset_type_prepare_head(AssetType $object) { global $langs, $conf, $user; - $h=0; + $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index 1a7b33569ce..a4d7a077aab 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -27,18 +27,18 @@ /* ******************************************************************** */ /* COLORS */ /* ******************************************************************** */ -$bar_color=array(0,0,0); -$bg_color=array(255,255,255); -$text_color=array(0,0,0); +$bar_color = array(0, 0, 0); +$bg_color = array(255, 255, 255); +$text_color = array(0, 0, 0); /* ******************************************************************** */ /* FONT FILE */ /* ******************************************************************** */ -if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc=constant('DOL_DEFAULT_TTF_BOLD'); +if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc = constant('DOL_DEFAULT_TTF_BOLD'); // Automatic-Detection of Font if running Windows // @CHANGE LDR -if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc=$_SERVER['WINDIR'].'\Fonts\arialbd.ttf'; +if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc = $_SERVER['WINDIR'].'\Fonts\arialbd.ttf'; if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path to a TTF font.'); @@ -50,7 +50,7 @@ if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path t * genbarcode is needed to render encodings other than EAN-12/EAN-13/ISBN */ -if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc=constant('PHP-BARCODE_PATH_COMMAND'); +if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc = constant('PHP-BARCODE_PATH_COMMAND'); else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION; @@ -69,16 +69,16 @@ function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png") { dol_syslog("barcode.lib.php::barcode_print $code $encoding $scale $mode"); - $bars=barcode_encode($code, $encoding); - if (! $bars || ! empty($bars['error'])) + $bars = barcode_encode($code, $encoding); + if (!$bars || !empty($bars['error'])) { // Return error message instead of array - if (empty($bars['error'])) $error='Bad Value '.$code.' for encoding '.$encoding; - else $error=$bars['error']; + if (empty($bars['error'])) $error = 'Bad Value '.$code.' for encoding '.$encoding; + else $error = $bars['error']; dol_syslog('barcode.lib.php::barcode_print '.$error, LOG_ERR); return $error; } - if (! $mode) $mode="png"; + if (!$mode) $mode = "png"; //if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']); //elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0); //else @@ -116,23 +116,23 @@ function barcode_encode($code, $encoding) (preg_match("/^ean$/i", $encoding)) || (($encoding) && (preg_match("/^isbn$/i", $encoding)) - && (( strlen($code)==9 || strlen($code)==10) || - (((preg_match("/^978/", $code) && strlen($code)==12) || - (strlen($code)==13))))) + && ((strlen($code) == 9 || strlen($code) == 10) || + (((preg_match("/^978/", $code) && strlen($code) == 12) || + (strlen($code) == 13))))) - || (( !isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding) )) + || ((!isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding))) && (preg_match("/^[0-9]{12,13}$/", $code))) ) { /* use built-in EAN-Encoder */ dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean"); - $bars=barcode_encode_ean($code, $encoding); + $bars = barcode_encode_ean($code, $encoding); } elseif (file_exists($genbarcode_loc)) // For example C39 { /* use genbarcode */ dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding); - $bars=barcode_encode_genbarcode($code, $encoding); + $bars = barcode_encode_genbarcode($code, $encoding); } else { @@ -160,14 +160,14 @@ function barcode_encode($code, $encoding) */ function barcode_gen_ean_sum($ean) { - $even=true; $esum=0; $osum=0; - $ln=strlen($ean)-1; - for ($i=$ln; $i>=0; $i--) + $even = true; $esum = 0; $osum = 0; + $ln = strlen($ean) - 1; + for ($i = $ln; $i >= 0; $i--) { - if ($even) $esum+=$ean[$i]; else $osum+=$ean[$i]; - $even=!$even; + if ($even) $esum += $ean[$i]; else $osum += $ean[$i]; + $even = !$even; } - return (10-((3*$esum+$osum)%10))%10; + return (10 - ((3 * $esum + $osum) % 10)) % 10; } /** @@ -179,48 +179,48 @@ function barcode_gen_ean_sum($ean) */ function barcode_encode_ean($ean, $encoding = "EAN-13") { - $digits=array(3211,2221,2122,1411,1132,1231,1114,1312,1213,3112); - $mirror=array("000000","001011","001101","001110","010011","011001","011100","010101","010110","011010"); - $guards=array("9a1a","1a1a1","a1a"); + $digits = array(3211, 2221, 2122, 1411, 1132, 1231, 1114, 1312, 1213, 3112); + $mirror = array("000000", "001011", "001101", "001110", "010011", "011001", "011100", "010101", "010110", "011010"); + $guards = array("9a1a", "1a1a1", "a1a"); - $ean=trim($ean); + $ean = trim($ean); if (preg_match("/[^0-9]/i", $ean)) { return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)"); } - $encoding=strtoupper($encoding); - if ($encoding=="ISBN") + $encoding = strtoupper($encoding); + if ($encoding == "ISBN") { - if (!preg_match("/^978/", $ean)) $ean="978".$ean; + if (!preg_match("/^978/", $ean)) $ean = "978".$ean; } - if (preg_match("/^978/", $ean)) $encoding="ISBN"; - if (strlen($ean)<12 || strlen($ean)>13) + if (preg_match("/^978/", $ean)) $encoding = "ISBN"; + if (strlen($ean) < 12 || strlen($ean) > 13) { return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)"); } - $ean=substr($ean, 0, 12); - $eansum=barcode_gen_ean_sum($ean); - $ean.=$eansum; - $line=$guards[0]; - for ($i=1;$i<13;$i++) + $ean = substr($ean, 0, 12); + $eansum = barcode_gen_ean_sum($ean); + $ean .= $eansum; + $line = $guards[0]; + for ($i = 1; $i < 13; $i++) { - $str=$digits[$ean[$i]]; - if ($i<7 && $mirror[$ean[0]][$i-1]==1) $line.=strrev($str); else $line.=$str; - if ($i==6) $line.=$guards[1]; + $str = $digits[$ean[$i]]; + if ($i < 7 && $mirror[$ean[0]][$i - 1] == 1) $line .= strrev($str); else $line .= $str; + if ($i == 6) $line .= $guards[1]; } - $line.=$guards[2]; + $line .= $guards[2]; /* create text */ - $pos=0; - $text=""; - for ($a=0;$a<13;$a++) + $pos = 0; + $text = ""; + for ($a = 0; $a < 13; $a++) { - if ($a>0) $text.=" "; - $text.="$pos:12:{$ean[$a]}"; - if ($a==0) $pos+=12; - elseif ($a==6) $pos+=12; - else $pos+=7; + if ($a > 0) $text .= " "; + $text .= "$pos:12:{$ean[$a]}"; + if ($a == 0) $pos += 12; + elseif ($a == 6) $pos += 12; + else $pos += 7; } return array( @@ -243,25 +243,25 @@ function barcode_encode_genbarcode($code, $encoding) global $genbarcode_loc; // Clean parameters - if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) $code=substr($code, 0, 12); - if (!$encoding) $encoding="ANY"; - $encoding=preg_replace("/[\\\|]/", "_", $encoding); - $code=preg_replace("/[\\\|]/", "_", $code); + if (preg_match("/^ean$/i", $encoding) && strlen($code) == 13) $code = substr($code, 0, 12); + if (!$encoding) $encoding = "ANY"; + $encoding = preg_replace("/[\\\|]/", "_", $encoding); + $code = preg_replace("/[\\\|]/", "_", $code); - $command=escapeshellarg($genbarcode_loc); + $command = escapeshellarg($genbarcode_loc); //$paramclear=" \"".str_replace("\"", "\\\"",$code)."\" \"".str_replace("\"", "\\\"",strtoupper($encoding))."\""; - $paramclear=" ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding)); + $paramclear = " ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding)); - $fullcommandclear=$command." ".$paramclear." 2>&1"; + $fullcommandclear = $command." ".$paramclear." 2>&1"; //print $fullcommandclear."
\n";exit; dol_syslog("Run command ".$fullcommandclear); - $fp=popen($fullcommandclear, "r"); + $fp = popen($fullcommandclear, "r"); if ($fp) { - $bars=fgets($fp, 1024); - $text=fgets($fp, 1024); - $encoding=fgets($fp, 1024); + $bars = fgets($fp, 1024); + $text = fgets($fp, 1024); + $encoding = fgets($fp, 1024); pclose($fp); } else @@ -270,7 +270,7 @@ function barcode_encode_genbarcode($code, $encoding) return false; } //var_dump($bars); - $ret=array( + $ret = array( "bars" => trim($bars), "text" => trim($text), "encoding" => trim($encoding), @@ -279,7 +279,7 @@ function barcode_encode_genbarcode($code, $encoding) //var_dump($ret); if (preg_match('/permission denied/i', $ret['bars'])) { - $ret['error']=$ret['bars']; $ret['bars']=''; + $ret['error'] = $ret['bars']; $ret['bars'] = ''; return $ret; } if (!$ret['bars']) return false; @@ -310,99 +310,99 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, //var_dump($font_loc); /* set defaults */ - if ($scale<1) $scale=2; - $total_y=(int) $total_y; - if ($total_y<1) $total_y=(int) $scale * 60; + if ($scale < 1) $scale = 2; + $total_y = (int) $total_y; + if ($total_y < 1) $total_y = (int) $scale * 60; if (!$space) - $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale); + $space = array('top'=>2 * $scale, 'bottom'=>2 * $scale, 'left'=>2 * $scale, 'right'=>2 * $scale); /* count total width */ - $xpos=0; - $width=true; - $ln=strlen($bars); - for ($i=0; $i<$ln; $i++) + $xpos = 0; + $width = true; + $ln = strlen($bars); + for ($i = 0; $i < $ln; $i++) { - $val=strtolower($bars[$i]); + $val = strtolower($bars[$i]); if ($width) { - $xpos+=$val*$scale; - $width=false; + $xpos += $val * $scale; + $width = false; continue; } if (preg_match("/[a-z]/", $val)) { /* tall bar */ - $val=ord($val)-ord('a')+1; + $val = ord($val) - ord('a') + 1; } - $xpos+=$val*$scale; - $width=true; + $xpos += $val * $scale; + $width = true; } /* allocate the image */ - $total_x=( $xpos )+$space['right']+$space['right']; - $xpos=$space['left']; - if (! function_exists("imagecreate")) + $total_x = ($xpos) + $space['right'] + $space['right']; + $xpos = $space['left']; + if (!function_exists("imagecreate")) { print "You don't have the gd2 extension enabled
\n"; return ""; } - $im=imagecreate($total_x, $total_y); + $im = imagecreate($total_x, $total_y); /* create two images */ - $col_bg=ImageColorAllocate($im, $bg_color[0], $bg_color[1], $bg_color[2]); - $col_bar=ImageColorAllocate($im, $bar_color[0], $bar_color[1], $bar_color[2]); - $col_text=ImageColorAllocate($im, $text_color[0], $text_color[1], $text_color[2]); - $height=round($total_y-($scale*10)); - $height2=round($total_y-$space['bottom']); + $col_bg = ImageColorAllocate($im, $bg_color[0], $bg_color[1], $bg_color[2]); + $col_bar = ImageColorAllocate($im, $bar_color[0], $bar_color[1], $bar_color[2]); + $col_text = ImageColorAllocate($im, $text_color[0], $text_color[1], $text_color[2]); + $height = round($total_y - ($scale * 10)); + $height2 = round($total_y - $space['bottom']); /* paint the bars */ - $width=true; - $ln=strlen($bars); - for ($i=0; $i<$ln; $i++) + $width = true; + $ln = strlen($bars); + for ($i = 0; $i < $ln; $i++) { - $val=strtolower($bars[$i]); + $val = strtolower($bars[$i]); if ($width) { - $xpos+=$val*$scale; - $width=false; + $xpos += $val * $scale; + $width = false; continue; } if (preg_match("/[a-z]/", $val)) { /* tall bar */ - $val=ord($val)-ord('a')+1; - $h=$height2; - } else $h=$height; - imagefilledrectangle($im, $xpos, $space['top'], $xpos+($val*$scale)-1, $h, $col_bar); - $xpos+=$val*$scale; - $width=true; + $val = ord($val) - ord('a') + 1; + $h = $height2; + } else $h = $height; + imagefilledrectangle($im, $xpos, $space['top'], $xpos + ($val * $scale) - 1, $h, $col_bar); + $xpos += $val * $scale; + $width = true; } - $chars=explode(" ", $text); + $chars = explode(" ", $text); reset($chars); - while (list($n, $v)=each($chars)) + while (list($n, $v) = each($chars)) { if (trim($v)) { - $inf=explode(":", $v); - $fontsize=$scale*($inf[1]/1.8); - $fontheight=$total_y-($fontsize/2.7)+2; - imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2, $fontheight, $col_text, $font_loc, $inf[2]); + $inf = explode(":", $v); + $fontsize = $scale * ($inf[1] / 1.8); + $fontheight = $total_y - ($fontsize / 2.7) + 2; + imagettftext($im, $fontsize, 0, $space['left'] + ($scale * $inf[0]) + 2, $fontheight, $col_text, $font_loc, $inf[2]); } } /* output the image */ - $mode=strtolower($mode); - if ($mode=='jpg' || $mode=='jpeg') + $mode = strtolower($mode); + if ($mode == 'jpg' || $mode == 'jpeg') { header("Content-Type: image/jpeg; name=\"barcode.jpg\""); imagejpeg($im); } - elseif ($mode=='gif') + elseif ($mode == 'gif') { header("Content-Type: image/gif; name=\"barcode.gif\""); imagegif($im); } - elseif (! empty($filebarcode)) // To wxrite into afile onto disk + elseif (!empty($filebarcode)) // To wxrite into afile onto disk { imagepng($im, $filebarcode); } diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index ca665637768..37ff7acad44 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -49,7 +49,7 @@ function categories_prepare_head($object, $type) $head[$h][2] = 'photos'; $h++; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&type='.$type; $head[$h][1] = $langs->trans("Translation"); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index eac9f404188..16d29af4a35 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -105,7 +105,7 @@ function societe_prepare_head(Societe $object) } } $supplier_module_enabled = 0; - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled=1; + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1; if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index 0082947d0c1..8edc81d7ee7 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -42,8 +42,8 @@ function contact_prepare_head(Contact $object) $head[$tab][2] = 'card'; $tab++; - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); @@ -59,7 +59,7 @@ function contact_prepare_head(Contact $object) $tab++; // Related items - if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->fournisseur->enabled)) + if (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled)) { $head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id; $head[$tab][1] = $langs->trans("Referers"); @@ -75,32 +75,32 @@ function contact_prepare_head(Contact $object) // Notes if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); + $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id; $head[$tab][1] = $langs->trans("Note"); - if($nbNote > 0) $head[$tab][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$tab][1] .= ''.$nbNote.''; $head[$tab][2] = 'note'; $tab++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->societe->dir_output."/contact/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; $head[$tab][2] = 'documents'; $tab++; // Agenda / Events $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; - $head[$tab][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$tab][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$tab][1].= '/'; - $head[$tab][1].= $langs->trans("Agenda"); + $head[$tab][1] .= '/'; + $head[$tab][1] .= $langs->trans("Agenda"); } $head[$tab][2] = 'agenda'; $tab++; diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index ec91a2dcc70..b7d3c45bee3 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -45,7 +45,7 @@ function contract_prepare_head(Contrat $object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -59,32 +59,32 @@ function contract_prepare_head(Contrat $object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index e7043a1798a..0dd8aeb1a32 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -33,7 +33,7 @@ */ function get_tz_array() { - $tzarray=array( + $tzarray = array( -11=>"Pacific/Midway", -10=>"Pacific/Fakaofo", -9=>"America/Anchorage", @@ -85,22 +85,22 @@ function getServerTimeZoneInt($refgmtdate = 'now') if (method_exists('DateTimeZone', 'getOffset')) { // Method 1 (include daylight) - $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow, '%Y'); $monthref=dol_print_date($gmtnow, '%m'); $dayref=dol_print_date($gmtnow, '%d'); - if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref; - elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01'; - else $newrefgmtdate=$yearref.'-01-01'; - $newrefgmtdate.='T00:00:00+00:00'; + $gmtnow = dol_now('gmt'); $yearref = dol_print_date($gmtnow, '%Y'); $monthref = dol_print_date($gmtnow, '%m'); $dayref = dol_print_date($gmtnow, '%d'); + if ($refgmtdate == 'now') $newrefgmtdate = $yearref.'-'.$monthref.'-'.$dayref; + elseif ($refgmtdate == 'summer') $newrefgmtdate = $yearref.'-08-01'; + else $newrefgmtdate = $yearref.'-01-01'; + $newrefgmtdate .= 'T00:00:00+00:00'; $localtz = new DateTimeZone(getServerTimeZoneString()); $localdt = new DateTime($newrefgmtdate, $localtz); - $tmp=-1*$localtz->getOffset($localdt); + $tmp = -1 * $localtz->getOffset($localdt); //print $refgmtdate.'='.$tmp; } else { - $tmp=0; + $tmp = 0; dol_print_error('', 'PHP version must be 5.3+'); } - $tz=round(($tmp<0?1:-1)*abs($tmp/3600)); + $tz = round(($tmp < 0 ? 1 : -1) * abs($tmp / 3600)); return $tz; } @@ -118,23 +118,23 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit) global $conf; if ($duration_value == 0) return $time; - if ($duration_unit == 'h') return $time + (3600*$duration_value); - if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value); + if ($duration_unit == 'h') return $time + (3600 * $duration_value); + if ($duration_unit == 'w') return $time + (3600 * 24 * 7 * $duration_value); - $deltastring='P'; + $deltastring = 'P'; - if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; } - if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; } - if ($duration_unit == 'd') { $deltastring.="D"; } - if ($duration_unit == 'm') { $deltastring.="M"; } - if ($duration_unit == 'y') { $deltastring.="Y"; } + if ($duration_value > 0) { $deltastring .= abs($duration_value); $sub = false; } + if ($duration_value < 0) { $deltastring .= abs($duration_value); $sub = true; } + if ($duration_unit == 'd') { $deltastring .= "D"; } + if ($duration_unit == 'm') { $deltastring .= "M"; } + if ($duration_unit == 'y') { $deltastring .= "Y"; } $date = new DateTime(); - if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); + if (!empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); $date->setTimestamp($time); $interval = new DateInterval($deltastring); - if($sub) $date->sub($interval); + if ($sub) $date->sub($interval); else $date->add($interval); return $date->getTimestamp(); @@ -152,7 +152,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit) */ function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0) { - $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; + $iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds; return $iResult; } @@ -182,26 +182,26 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l { global $langs; - if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours - if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days + if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours + if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec') { - if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US + if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US - $sTime=''; - $sDay=0; - $sWeek=0; + $sTime = ''; + $sDay = 0; + $sWeek = 0; if ($iSecond >= $lengthOfDay) { - for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) + for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay) { $sDay++; - $iSecond-=$lengthOfDay; + $iSecond -= $lengthOfDay; } $dayTranslate = $langs->trans("Day"); - if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); + if ($iSecond >= ($lengthOfDay * 2)) $dayTranslate = $langs->trans("Days"); } if ($lengthOfWeek < 7) @@ -210,70 +210,70 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l { if ($sDay >= $lengthOfWeek) { - $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); + $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek); $sDay = $sDay % $lengthOfWeek; $weekTranslate = $langs->trans("DurationWeek"); if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); - $sTime.=$sWeek.' '.$weekTranslate.' '; + $sTime .= $sWeek.' '.$weekTranslate.' '; } } } - if ($sDay>0) + if ($sDay > 0) { $dayTranslate = $langs->trans("Day"); if ($sDay > 1) $dayTranslate = $langs->trans("Days"); - $sTime.=$sDay.' '.$dayTranslate.' '; + $sTime .= $sDay.' '.$dayTranslate.' '; } if ($format == 'all') { if ($iSecond || empty($sDay)) { - $sTime.= dol_print_date($iSecond, 'hourduration', true); + $sTime .= dol_print_date($iSecond, 'hourduration', true); } } elseif ($format == 'allhourminsec') { - return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60))).':'.sprintf("%02d", ((int) ($iSecond % 60))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))).':'.sprintf("%02d", ((int) ($iSecond % 60))); } elseif ($format == 'allhourmin') { - return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))); } elseif ($format == 'allhour') { - return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))); } } elseif ($format == 'hour') // only hour part { - $sTime=dol_print_date($iSecond, '%H', true); + $sTime = dol_print_date($iSecond, '%H', true); } elseif ($format == 'fullhour') { if (!empty($iSecond)) { - $iSecond=$iSecond/3600; + $iSecond = $iSecond / 3600; } else { - $iSecond=0; + $iSecond = 0; } - $sTime=$iSecond; + $sTime = $iSecond; } elseif ($format == 'min') // only min part { - $sTime=dol_print_date($iSecond, '%M', true); + $sTime = dol_print_date($iSecond, '%M', true); } elseif ($format == 'sec') // only sec part { - $sTime=dol_print_date($iSecond, '%S', true); + $sTime = dol_print_date($iSecond, '%S', true); } elseif ($format == 'month') // only month part { - $sTime=dol_print_date($iSecond, '%m', true); + $sTime = dol_print_date($iSecond, '%m', true); } elseif ($format == 'year') // only year part { - $sTime=dol_print_date($iSecond, '%Y', true); + $sTime = dol_print_date($iSecond, '%Y', true); } return trim($sTime); } @@ -292,19 +292,19 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand = 0) { global $db; - $sqldate=""; + $sqldate = ""; if ($month_date > 0) { if ($year_date > 0 && empty($day_date)) { - $sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false)); - $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'"; - } elseif ($year_date > 0 && ! empty($day_date)) { - $sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); - $sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'"; + $sqldate .= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false)); + $sqldate .= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'"; + } elseif ($year_date > 0 && !empty($day_date)) { + $sqldate .= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); + $sqldate .= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'"; } else - $sqldate.= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; - } elseif ($year_date > 0){ - $sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); - $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; + $sqldate .= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; + } elseif ($year_date > 0) { + $sqldate .= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); + $sqldate .= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; } return $sqldate; } @@ -330,7 +330,7 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $exclu */ function dol_stringtotime($string, $gm = 1) { - $reg=array(); + $reg = array(); // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used. if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg)) { @@ -343,9 +343,9 @@ function dol_stringtotime($string, $gm = 1) $shour = $reg[4]; $smin = $reg[5]; $ssec = $reg[6]; - if ($syear < 50) $syear+=1900; - if ($syear >= 50 && $syear < 100) $syear+=2000; - $string=sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); + if ($syear < 50) $syear += 1900; + if ($syear >= 50 && $syear < 100) $syear += 2000; + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); } elseif ( preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339) @@ -359,12 +359,12 @@ function dol_stringtotime($string, $gm = 1) $shour = $reg[4]; $smin = $reg[5]; $ssec = $reg[6]; - $string=sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); } - $string=preg_replace('/([^0-9])/i', '', $string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm?1:0)); + $string = preg_replace('/([^0-9])/i', '', $string); + $tmp = $string.'000000'; + $date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm ? 1 : 0)); return $date; } @@ -378,9 +378,9 @@ function dol_stringtotime($string, $gm = 1) */ function dol_get_prev_day($day, $month, $year) { - $time=dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); - $time-=24*60*60; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); + $time -= 24 * 60 * 60; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -393,9 +393,9 @@ function dol_get_prev_day($day, $month, $year) */ function dol_get_next_day($day, $month, $year) { - $time=dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); - $time+=24*60*60; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); + $time += 24 * 60 * 60; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -414,7 +414,7 @@ function dol_get_prev_month($month, $year) } else { - $prev_month = $month-1; + $prev_month = $month - 1; $prev_year = $year; } return array('year' => $prev_year, 'month' => $prev_month); @@ -453,9 +453,9 @@ function dol_get_prev_week($day, $week, $month, $year) { $tmparray = dol_get_first_day_week($day, $month, $year); - $time=dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0); - $time-=24*60*60*7; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0); + $time -= 24 * 60 * 60 * 7; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -471,9 +471,9 @@ function dol_get_next_week($day, $week, $month, $year) { $tmparray = dol_get_first_day_week($day, $month, $year); - $time=dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0); - $time+=24*60*60*7; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0); + $time += 24 * 60 * 60 * 7; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -515,7 +515,7 @@ function dol_get_last_day($year, $month = 12, $gm = false) } // On se deplace au debut du mois suivant, et on retire un jour - $datelim=dol_mktime(23, 59, 59, $month, 1, $year, $gm); + $datelim = dol_mktime(23, 59, 59, $month, 1, $year, $gm); $datelim -= (3600 * 24); return $datelim; @@ -537,57 +537,57 @@ function dol_get_first_day_week($day, $month, $year, $gm = false) $date = dol_mktime(0, 0, 0, $month, $day, $year, $gm); //Checking conf of start week - $start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1); + $start_week = (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1); - $tmparray = dol_getdate($date, true); // detail of current day + $tmparray = dol_getdate($date, true); // detail of current day //Calculate days = offset from current day $days = $start_week - $tmparray['wday']; - if ($days>=1) $days=7-$days; + if ($days >= 1) $days = 7 - $days; $days = abs($days); - $seconds = $days*24*60*60; + $seconds = $days * 24 * 60 * 60; //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'
'; //Get first day of week - $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters + $tmpdaytms = date($tmparray[0]) - $seconds; // $tmparray[0] is day of parameters $tmpday = date("d", $tmpdaytms); //Check first day of week is in same month than current day or not - if ($tmpday>$day) + if ($tmpday > $day) { - $prev_month = $month-1; - $prev_year = $year; + $prev_month = $month - 1; + $prev_year = $year; - if ($prev_month==0) + if ($prev_month == 0) { $prev_month = 12; - $prev_year = $year-1; + $prev_year = $year - 1; } } else { $prev_month = $month; - $prev_year = $year; + $prev_year = $year; } $tmpmonth = $prev_month; $tmpyear = $prev_year; //Get first day of next week - $tmptime=dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0); - $tmptime-=24*60*60*7; - $tmparray=dol_getdate($tmptime, true); - $prev_day = $tmparray['mday']; + $tmptime = dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0); + $tmptime -= 24 * 60 * 60 * 7; + $tmparray = dol_getdate($tmptime, true); + $prev_day = $tmparray['mday']; //Check prev day of week is in same month than first day or not if ($prev_day > $tmpday) { - $prev_month = $month-1; - $prev_year = $year; + $prev_month = $month - 1; + $prev_year = $year; - if ($prev_month==0) + if ($prev_month == 0) { $prev_month = 12; - $prev_year = $year-1; + $prev_year = $year - 1; } } @@ -626,11 +626,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', if ($includesunday < 0) $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); - $i=0; - while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) + $i = 0; + while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd)) && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) { - $ferie=false; + $ferie = false; $jour = date("d", $timestampStart); $mois = date("m", $timestampStart); @@ -638,19 +638,19 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ... // Do not use this anymore, use instead the dictionary of public holidays. - if (! empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) + if (!empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) { - $arrayofdaystring=explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); - foreach($arrayofdaystring as $daystring) + $arrayofdaystring = explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); + foreach ($arrayofdaystring as $daystring) { - $tmp=explode('-', $daystring); + $tmp = explode('-', $daystring); if ($tmp[2]) { - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true; + if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie = true; } else { - if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true; + if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie = true; } } } @@ -659,26 +659,26 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', // Loop on public holiday defined into hrm_public_holiday $sql = "SELECT code, entity, fk_country, dayrule, year, month, day, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday"; - $sql.= " WHERE active = 1 and fk_country IN (0".($country_id > 0 ? ", ".$country_id : 0).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday"; + $sql .= " WHERE active = 1 and fk_country IN (0".($country_id > 0 ? ", ".$country_id : 0).")"; $resql = $db->query($sql); if ($resql) { $num_rows = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num_rows) { $obj = $db->fetch_object($resql); - if (! empty($obj->dayrule) && $obj->dayrule != 'date') // For example 'easter', '...' + if (!empty($obj->dayrule) && $obj->dayrule != 'date') // For example 'easter', '...' { $specialdayrule[$obj->dayrule] = $obj->dayrule; } else { $match = 1; - if (! empty($obj->year) && $obj->year != $annee) $match = 0; + if (!empty($obj->year) && $obj->year != $annee) $match = 0; if ($obj->month != $mois) $match = 0; if ($obj->day != $jour) $match = 0; @@ -701,7 +701,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; // Easter (sunday) } @@ -719,7 +719,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_lundi_ascension = date("d", $date_lundi_paques); $mois_lundi_ascension = date("m", $date_lundi_paques); - if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; + if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie = true; // Easter (monday) } @@ -737,7 +737,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_ascension = date("d", $date_ascension); $mois_ascension = date("m", $date_ascension); - if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; + if ($jour_ascension == $jour && $mois_ascension == $mois) $ferie = true; // Ascension (thursday) } @@ -755,7 +755,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; // "Pentecote" (sunday) } if (in_array('pentecotemonday', $specialdayrule)) @@ -772,7 +772,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; // "Pentecote" (monday) } @@ -785,12 +785,12 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), - date("d", $date_paques) -2, + date("d", $date_paques) - 2, date("Y", $date_paques) ); $jour_viernes = date("d", $date_viernes); $mois_viernes = date("m", $date_viernes); - if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; + if ($jour_viernes == $jour && $mois_viernes == $mois) $ferie = true; //Viernes Santo } @@ -808,7 +808,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_fronleichnam = date("d", $date_fronleichnam); $mois_fronleichnam = date("m", $date_fronleichnam); - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; + if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie = true; // Fronleichnam } @@ -819,11 +819,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $jour_semaine = jddayofweek($jour_julien, 0); if ($includesaturday) //Saturday (6) and Sunday (0) { - if ($jour_semaine == 6) $ferie=true; + if ($jour_semaine == 6) $ferie = true; } if ($includesunday) //Saturday (6) and Sunday (0) { - if($jour_semaine == 0) $ferie=true; + if ($jour_semaine == 0) $ferie = true; } } @@ -831,7 +831,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', if ($ferie) $nbFerie++; // Increase number of days (on go up into loop) - $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); + $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd'); //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); $i++; @@ -862,7 +862,7 @@ function num_between_day($timestampStart, $timestampEnd, $lastday = 0) { $bit = 1; } - $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; + $nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit; } //print ($timestampEnd - $timestampStart) - $lastday; return $nbjours; @@ -882,15 +882,15 @@ function num_between_day($timestampStart, $timestampEnd, $lastday = 0) */ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '') { - global $langs,$mysoc; + global $langs, $mysoc; - if (empty($country_code)) $country_code=$mysoc->country_code; + if (empty($country_code)) $country_code = $mysoc->country_code; dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); // Check parameters - if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; - if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; + if (!is_int($timestampStart) && !is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; + if (!is_int($timestampEnd) && !is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; if ($timestampStart < $timestampEnd) @@ -898,14 +898,14 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); $nbOpenDay = $numdays - $numholidays; - $nbOpenDay.= " " . $langs->trans("Days"); - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); + $nbOpenDay .= " ".$langs->trans("Days"); + if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); } elseif ($timestampStart == $timestampEnd) { - $nbOpenDay=$lastday; - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); + $nbOpenDay = $lastday; + if ($inhour == 1) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); } else @@ -926,7 +926,7 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, */ function monthArray($outputlangs, $short = 0) { - $montharray = array ( + $montharray = array( 1 => $outputlangs->trans("Month01"), 2 => $outputlangs->trans("Month02"), 3 => $outputlangs->trans("Month03"), @@ -941,9 +941,9 @@ function monthArray($outputlangs, $short = 0) 12 => $outputlangs->trans("Month12") ); - if (! empty($short)) + if (!empty($short)) { - $montharray = array ( + $montharray = array( 1 => $outputlangs->trans("MonthShort01"), 2 => $outputlangs->trans("MonthShort02"), 3 => $outputlangs->trans("MonthShort03"), @@ -973,7 +973,7 @@ function getWeekNumbersOfMonth($month, $year) { $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year); $TWeek = array(); - for($day = 1; $day < $nb_days; $day++) { + for ($day = 1; $day < $nb_days; $day++) { $week_number = getWeekNumber($day, $month, $year); $TWeek[$week_number] = $week_number; } @@ -990,8 +990,8 @@ function getWeekNumbersOfMonth($month, $year) function getFirstDayOfEachWeek($TWeek, $year) { $TFirstDayOfWeek = array(); - foreach($TWeek as $weekNb) { - if(in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année + foreach ($TWeek as $weekNb) { + if (in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') $year++; //Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année $TFirstDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb)); } return $TFirstDayOfWeek; @@ -1007,7 +1007,7 @@ function getFirstDayOfEachWeek($TWeek, $year) function getLastDayOfEachWeek($TWeek, $year) { $TLastDayOfWeek = array(); - foreach($TWeek as $weekNb) { + foreach ($TWeek as $weekNb) { $TLastDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb.'+6 days')); } return $TLastDayOfWeek; diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index 6840e81a646..38e847bb3c1 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -42,11 +42,11 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu { global $db, $conf, $langs; - $idprod=$line->fk_product; - $label=(! empty($line->label)?$line->label:(! empty($line->libelle)?$line->libelle:'')); - $desc=(! empty($line->desc)?$line->desc:(! empty($line->description)?$line->description:'')); - $ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders - $note=(! empty($line->note)?$line->note:''); + $idprod = $line->fk_product; + $label = (!empty($line->label) ? $line->label : (!empty($line->libelle) ? $line->libelle : '')); + $desc = (!empty($line->desc) ? $line->desc : (!empty($line->description) ? $line->description : '')); + $ref_supplier = (!empty($line->ref_supplier) ? $line->ref_supplier : (!empty($line->ref_fourn) ? $line->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders + $note = (!empty($line->note) ? $line->note : ''); if ($issupplierline) $prodser = new ProductFournisseur($db); else $prodser = new Product($db); @@ -55,57 +55,57 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } // Description short of product line - $libelleproduitservice=$label; + $libelleproduitservice = $label; // Description long of product line if ($desc && ($desc != $label)) { if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); } elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); } elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { if ($idprod) { - if (empty($hidedesc)) $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); + if (empty($hidedesc)) $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } else { - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } @@ -118,7 +118,7 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu { $prefix_prodserv = ""; $ref_prodserv = ""; - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { if ($prodser->isService()) { @@ -132,34 +132,34 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu if (empty($hideref)) { - if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref + if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref else $ref_prodserv = $prodser->ref; // Show local ref only $ref_prodserv .= " - "; } - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; + $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; } } - if (! empty($line->date_start) || ! empty($line->date_end)) + if (!empty($line->date_start) || !empty($line->date_end)) { - $format='day'; + $format = 'day'; // Show duration if exists if ($line->date_start && $line->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')'; } - if ($line->date_start && ! $line->date_end) + if ($line->date_start && !$line->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')'; } - if (! $line->date_start && $line->date_end) + if (!$line->date_start && $line->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $period); + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period); //print $libelleproduitservice; } diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 16d7d3d8a97..b2280657481 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -33,10 +33,10 @@ function donation_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php'; + $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation.php'; $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; - $h ++; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -44,7 +44,7 @@ function donation_admin_prepare_head() // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin'); - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; @@ -67,10 +67,10 @@ function donation_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; - $h ++; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -80,25 +80,25 @@ function donation_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->don->dir_output . '/' . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index a49e501af78..4dbb418855a 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -36,15 +36,15 @@ function ecm_prepare_dasboard_head($object) $h = 0; $head = array(); - $helptext =$langs->trans("ECMAreaDesc").'
'; - $helptext.=$langs->trans("ECMAreaDesc2"); + $helptext = $langs->trans("ECMAreaDesc").'
'; + $helptext .= $langs->trans("ECMAreaDesc2"); $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php'; $head[$h][1] = $langs->trans("ECMSectionsManual").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); $head[$h][2] = 'index'; $h++; - if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) + if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php'; $head[$h][1] = $langs->trans("ECMSectionsAuto").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index cb4e5cf8b29..839be4c4e3d 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -39,16 +39,16 @@ function emailing_prepare_head(Mailing $object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; $head[$h][1] = $langs->trans("MailRecipients"); - if ($object->nbemail > 0) $head[$h][1].= ''.$object->nbemail.''; + if ($object->nbemail > 0) $head[$h][1] .= ''.$object->nbemail.''; $head[$h][2] = 'targets'; $h++; } - if ( empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) + if (empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); diff --git a/htdocs/core/lib/expedition.lib.php b/htdocs/core/lib/expedition.lib.php index 7c329940b2d..fc1ca494d36 100644 --- a/htdocs/core/lib/expedition.lib.php +++ b/htdocs/core/lib/expedition.lib.php @@ -35,7 +35,7 @@ function expedition_prepare_head(Expedition $object) { global $langs, $conf, $user; - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); + if (!empty($conf->expedition->enabled)) $langs->load("sendings"); $langs->load("orders"); $h = 0; @@ -48,10 +48,10 @@ function expedition_prepare_head(Expedition $object) $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; $head[$h][1] = $langs->trans("Shipment"); - $hselected=$h; + $hselected = $h; $h++; - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; $head[$h][1] = $langs->trans("Receivings"); @@ -83,7 +83,7 @@ function expedition_admin_prepare_head() $h++; - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) + if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; $head[$h][1] = $langs->trans("Shipment"); @@ -92,7 +92,7 @@ function expedition_admin_prepare_head() } - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) + if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -100,7 +100,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) + if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); @@ -108,7 +108,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; $head[$h][1] = $langs->trans("Receivings"); @@ -116,7 +116,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT.'/admin/livraison_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -124,7 +124,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT.'/admin/livraisondet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); diff --git a/htdocs/core/lib/expensereport.lib.php b/htdocs/core/lib/expensereport.lib.php index caef261b277..2767af2e792 100644 --- a/htdocs/core/lib/expensereport.lib.php +++ b/htdocs/core/lib/expensereport.lib.php @@ -34,7 +34,7 @@ function expensereport_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -47,28 +47,28 @@ function expensereport_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } - $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index d707063bbe8..8d0809f9768 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -51,7 +51,7 @@ function fichinter_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('InterventionContact'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -68,7 +68,7 @@ function fichinter_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; $objectres = new Dolresource($db); $linked_resources = $objectres->getElementResources('fichinter', $object->id); - $nbResource = (is_array($linked_resources)?count($linked_resources):0); + $nbResource = (is_array($linked_resources) ?count($linked_resources) : 0); // if (is_array($objectres->available_resources)) // { // foreach ($objectres->available_resources as $modresources => $resources) @@ -83,7 +83,7 @@ function fichinter_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); - if ($nbResource > 0) $head[$h][1].= ''.$nbResource.''; + if ($nbResource > 0) $head[$h][1] .= ''.$nbResource.''; $head[$h][2] = 'resource'; $h++; } @@ -91,23 +91,23 @@ function fichinter_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->ficheinter->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/fiscalyear.lib.php b/htdocs/core/lib/fiscalyear.lib.php index 14a23cc22c2..f54772c2339 100644 --- a/htdocs/core/lib/fiscalyear.lib.php +++ b/htdocs/core/lib/fiscalyear.lib.php @@ -34,7 +34,7 @@ function fiscalyear_prepare_head(Fiscalyear $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -45,7 +45,7 @@ function fiscalyear_prepare_head(Fiscalyear $object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'fiscalyear'); - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/format_cards.lib.php b/htdocs/core/lib/format_cards.lib.php index 7135082fac9..c46cd150a51 100644 --- a/htdocs/core/lib/format_cards.lib.php +++ b/htdocs/core/lib/format_cards.lib.php @@ -38,22 +38,22 @@ if ($resql) { while ($row = $db->fetch_array($resql)) { - $_Avery_Labels[$row['code']]['name']=$row['name']; - $_Avery_Labels[$row['code']]['paper-size']=$row['paper_size']; - $_Avery_Labels[$row['code']]['orientation']=$row['orientation']; - $_Avery_Labels[$row['code']]['metric']=$row['metric']; - $_Avery_Labels[$row['code']]['marginLeft']=$row['leftmargin']; - $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; - $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; - $_Avery_Labels[$row['code']]['NX']=$row['nx']; - $_Avery_Labels[$row['code']]['NY']=$row['ny']; - $_Avery_Labels[$row['code']]['SpaceX']=$row['spacex']; - $_Avery_Labels[$row['code']]['SpaceY']=$row['spacey']; - $_Avery_Labels[$row['code']]['width']=$row['width']; - $_Avery_Labels[$row['code']]['height']=$row['height']; - $_Avery_Labels[$row['code']]['font-size']=$row['font_size']; - $_Avery_Labels[$row['code']]['custom_x']=$row['custom_x']; - $_Avery_Labels[$row['code']]['custom_y']=$row['custom_y']; + $_Avery_Labels[$row['code']]['name'] = $row['name']; + $_Avery_Labels[$row['code']]['paper-size'] = $row['paper_size']; + $_Avery_Labels[$row['code']]['orientation'] = $row['orientation']; + $_Avery_Labels[$row['code']]['metric'] = $row['metric']; + $_Avery_Labels[$row['code']]['marginLeft'] = $row['leftmargin']; + $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; + $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; + $_Avery_Labels[$row['code']]['NX'] = $row['nx']; + $_Avery_Labels[$row['code']]['NY'] = $row['ny']; + $_Avery_Labels[$row['code']]['SpaceX'] = $row['spacex']; + $_Avery_Labels[$row['code']]['SpaceY'] = $row['spacey']; + $_Avery_Labels[$row['code']]['width'] = $row['width']; + $_Avery_Labels[$row['code']]['height'] = $row['height']; + $_Avery_Labels[$row['code']]['font-size'] = $row['font_size']; + $_Avery_Labels[$row['code']]['custom_x'] = $row['custom_x']; + $_Avery_Labels[$row['code']]['custom_y'] = $row['custom_y']; } } else @@ -62,7 +62,7 @@ else } // We add characteristics to the name -foreach($_Avery_Labels as $key => $val) +foreach ($_Avery_Labels as $key => $val) { - $_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; + $_Avery_Labels[$key]['name'] .= ' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; } diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 9336d9b221f..3b41f2620b4 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -48,7 +48,7 @@ function facturefourn_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -62,11 +62,11 @@ function facturefourn_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } @@ -75,10 +75,10 @@ function facturefourn_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -116,12 +116,12 @@ function ordersupplier_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } - if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) + if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { $langs->load("stocks"); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; @@ -139,32 +139,32 @@ function ordersupplier_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->fournisseur->dir_output."/commande/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 34034abb280..2dc159170a7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1660,7 +1660,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $morehtmlref .= ''; } } - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && ($conf->global->MAIN_SHOW_TECHNICAL_ID == '1' || preg_match('/'.preg_quote($object->element, '/').'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && ! empty($object->id)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && ($conf->global->MAIN_SHOW_TECHNICAL_ID == '1' || preg_match('/'.preg_quote($object->element, '/').'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && !empty($object->id)) { $morehtmlref .= '
'; $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id; @@ -3222,7 +3222,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_off', 'uparrow', '1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected' ); - if (! isset($arrayconvpictotomarginleftonly[$pictowithouttext])) { + if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) { $marginleftonlyshort = 0; } @@ -3238,7 +3238,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'title_agenda'=>'bg-infoxbox-action', 'list-alt'=>'imgforviewmode', 'calendar'=>'imgforviewmode', 'calendarweek'=>'imgforviewmode', 'calendarmonth'=>'imgforviewmode', 'calendarday'=>'imgforviewmode', 'calendarperuser'=>'imgforviewmode' ); - if (! empty($arrayconvpictotomorcess[$pictowithouttext])) { + if (!empty($arrayconvpictotomorcess[$pictowithouttext])) { $morecss .= ($morecss ? ' ' : '').$arrayconvpictotomorcess[$pictowithouttext]; } @@ -5649,7 +5649,7 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1) $allowed_tags_string = '<'.$allowed_tags_string.'>'; if ($cleanalsosomestyles) { - $stringtoclean = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/', '', $stringtoclean); // Note: If hacker try to introduce css comment into string to bypass this regex, the string must also be encoded by the dol_htmlentitiesbr during output so it become harmless + $stringtoclean = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/', '', $stringtoclean); // Note: If hacker try to introduce css comment into string to bypass this regex, the string must also be encoded by the dol_htmlentitiesbr during output so it become harmless } $temp = strip_tags($stringtoclean, $allowed_tags_string); diff --git a/htdocs/core/lib/functions_ch.lib.php b/htdocs/core/lib/functions_ch.lib.php index 353c8d0a2ac..04e74837853 100644 --- a/htdocs/core/lib/functions_ch.lib.php +++ b/htdocs/core/lib/functions_ch.lib.php @@ -32,139 +32,139 @@ function dol_ch_controle_bvrb($bvrb) { // Init array for control - $tableau[0][0]=0; - $tableau[0][1]=9; - $tableau[0][2]=4; - $tableau[0][3]=6; - $tableau[0][4]=8; - $tableau[0][5]=2; - $tableau[0][6]=7; - $tableau[0][7]=1; - $tableau[0][8]=3; - $tableau[0][9]=5; - $tableau[0][10]=0; + $tableau[0][0] = 0; + $tableau[0][1] = 9; + $tableau[0][2] = 4; + $tableau[0][3] = 6; + $tableau[0][4] = 8; + $tableau[0][5] = 2; + $tableau[0][6] = 7; + $tableau[0][7] = 1; + $tableau[0][8] = 3; + $tableau[0][9] = 5; + $tableau[0][10] = 0; - $tableau[1][0]=9; - $tableau[1][1]=4; - $tableau[1][2]=6; - $tableau[1][3]=8; - $tableau[1][4]=2; - $tableau[1][5]=7; - $tableau[1][6]=1; - $tableau[1][7]=3; - $tableau[1][8]=5; - $tableau[1][9]=0; - $tableau[1][10]=9; + $tableau[1][0] = 9; + $tableau[1][1] = 4; + $tableau[1][2] = 6; + $tableau[1][3] = 8; + $tableau[1][4] = 2; + $tableau[1][5] = 7; + $tableau[1][6] = 1; + $tableau[1][7] = 3; + $tableau[1][8] = 5; + $tableau[1][9] = 0; + $tableau[1][10] = 9; - $tableau[2][0]=4; - $tableau[2][1]=6; - $tableau[2][2]=8; - $tableau[2][3]=2; - $tableau[2][4]=7; - $tableau[2][5]=1; - $tableau[2][6]=3; - $tableau[2][7]=5; - $tableau[2][8]=0; - $tableau[2][9]=9; - $tableau[2][10]=8; + $tableau[2][0] = 4; + $tableau[2][1] = 6; + $tableau[2][2] = 8; + $tableau[2][3] = 2; + $tableau[2][4] = 7; + $tableau[2][5] = 1; + $tableau[2][6] = 3; + $tableau[2][7] = 5; + $tableau[2][8] = 0; + $tableau[2][9] = 9; + $tableau[2][10] = 8; - $tableau[3][0]=6; - $tableau[3][1]=8; - $tableau[3][2]=2; - $tableau[3][3]=7; - $tableau[3][4]=1; - $tableau[3][5]=3; - $tableau[3][6]=5; - $tableau[3][7]=0; - $tableau[3][8]=9; - $tableau[3][9]=4; - $tableau[3][10]=7; + $tableau[3][0] = 6; + $tableau[3][1] = 8; + $tableau[3][2] = 2; + $tableau[3][3] = 7; + $tableau[3][4] = 1; + $tableau[3][5] = 3; + $tableau[3][6] = 5; + $tableau[3][7] = 0; + $tableau[3][8] = 9; + $tableau[3][9] = 4; + $tableau[3][10] = 7; - $tableau[4][0]=8; - $tableau[4][1]=2; - $tableau[4][2]=7; - $tableau[4][3]=1; - $tableau[4][4]=3; - $tableau[4][5]=5; - $tableau[4][6]=0; - $tableau[4][7]=9; - $tableau[4][8]=4; - $tableau[4][9]=6; - $tableau[4][10]=6; + $tableau[4][0] = 8; + $tableau[4][1] = 2; + $tableau[4][2] = 7; + $tableau[4][3] = 1; + $tableau[4][4] = 3; + $tableau[4][5] = 5; + $tableau[4][6] = 0; + $tableau[4][7] = 9; + $tableau[4][8] = 4; + $tableau[4][9] = 6; + $tableau[4][10] = 6; - $tableau[5][0]=2; - $tableau[5][1]=7; - $tableau[5][2]=1; - $tableau[5][3]=3; - $tableau[5][4]=5; - $tableau[5][5]=0; - $tableau[5][6]=9; - $tableau[5][7]=4; - $tableau[5][8]=6; - $tableau[5][9]=8; - $tableau[5][10]=5; + $tableau[5][0] = 2; + $tableau[5][1] = 7; + $tableau[5][2] = 1; + $tableau[5][3] = 3; + $tableau[5][4] = 5; + $tableau[5][5] = 0; + $tableau[5][6] = 9; + $tableau[5][7] = 4; + $tableau[5][8] = 6; + $tableau[5][9] = 8; + $tableau[5][10] = 5; - $tableau[6][0]=7; - $tableau[6][1]=1; - $tableau[6][2]=3; - $tableau[6][3]=5; - $tableau[6][4]=0; - $tableau[6][5]=9; - $tableau[6][6]=4; - $tableau[6][7]=6; - $tableau[6][8]=8; - $tableau[6][9]=2; - $tableau[6][10]=4; + $tableau[6][0] = 7; + $tableau[6][1] = 1; + $tableau[6][2] = 3; + $tableau[6][3] = 5; + $tableau[6][4] = 0; + $tableau[6][5] = 9; + $tableau[6][6] = 4; + $tableau[6][7] = 6; + $tableau[6][8] = 8; + $tableau[6][9] = 2; + $tableau[6][10] = 4; - $tableau[7][0]=1; - $tableau[7][1]=3; - $tableau[7][2]=5; - $tableau[7][3]=0; - $tableau[7][4]=9; - $tableau[7][5]=4; - $tableau[7][6]=6; - $tableau[7][7]=8; - $tableau[7][8]=2; - $tableau[7][9]=7; - $tableau[7][10]=3; + $tableau[7][0] = 1; + $tableau[7][1] = 3; + $tableau[7][2] = 5; + $tableau[7][3] = 0; + $tableau[7][4] = 9; + $tableau[7][5] = 4; + $tableau[7][6] = 6; + $tableau[7][7] = 8; + $tableau[7][8] = 2; + $tableau[7][9] = 7; + $tableau[7][10] = 3; - $tableau[8][0]=3; - $tableau[8][1]=5; - $tableau[8][2]=0; - $tableau[8][3]=9; - $tableau[8][4]=4; - $tableau[8][5]=6; - $tableau[8][6]=8; - $tableau[8][7]=2; - $tableau[8][8]=7; - $tableau[8][9]=1; - $tableau[8][10]=2; + $tableau[8][0] = 3; + $tableau[8][1] = 5; + $tableau[8][2] = 0; + $tableau[8][3] = 9; + $tableau[8][4] = 4; + $tableau[8][5] = 6; + $tableau[8][6] = 8; + $tableau[8][7] = 2; + $tableau[8][8] = 7; + $tableau[8][9] = 1; + $tableau[8][10] = 2; - $tableau[9][0]=5; - $tableau[9][1]=0; - $tableau[9][2]=9; - $tableau[9][3]=4; - $tableau[9][4]=6; - $tableau[9][5]=8; - $tableau[9][6]=2; - $tableau[9][7]=7; - $tableau[9][8]=1; - $tableau[9][9]=3; - $tableau[9][10]=1; + $tableau[9][0] = 5; + $tableau[9][1] = 0; + $tableau[9][2] = 9; + $tableau[9][3] = 4; + $tableau[9][4] = 6; + $tableau[9][5] = 8; + $tableau[9][6] = 2; + $tableau[9][7] = 7; + $tableau[9][8] = 1; + $tableau[9][9] = 3; + $tableau[9][10] = 1; // Clean data - $bv=str_replace(' ', '', $bvrb); + $bv = str_replace(' ', '', $bvrb); // Make control - $report=0; - while (dol_strlen($bv)>1) + $report = 0; + while (dol_strlen($bv) > 1) { - $match=substr($bv, 0, 1); - $report=$tableau[$report][$match]; - $bv=substr($bv, 1); + $match = substr($bv, 0, 1); + $report = $tableau[$report][$match]; + $bv = substr($bv, 1); } - $controle=$tableau[$report][10]; + $controle = $tableau[$report][10]; - return ($controle==$bv); + return ($controle == $bv); } diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index ac5cfab832f..ae0eb86882e 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -35,11 +35,11 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = { //declaring of global variables global $conf; - $USE_PROXY=empty($conf->global->MAIN_PROXY_USE)?0:$conf->global->MAIN_PROXY_USE; - $PROXY_HOST=empty($conf->global->MAIN_PROXY_HOST)?0:$conf->global->MAIN_PROXY_HOST; - $PROXY_PORT=empty($conf->global->MAIN_PROXY_PORT)?0:$conf->global->MAIN_PROXY_PORT; - $PROXY_USER=empty($conf->global->MAIN_PROXY_USER)?0:$conf->global->MAIN_PROXY_USER; - $PROXY_PASS=empty($conf->global->MAIN_PROXY_PASS)?0:$conf->global->MAIN_PROXY_PASS; + $USE_PROXY = empty($conf->global->MAIN_PROXY_USE) ? 0 : $conf->global->MAIN_PROXY_USE; + $PROXY_HOST = empty($conf->global->MAIN_PROXY_HOST) ? 0 : $conf->global->MAIN_PROXY_HOST; + $PROXY_PORT = empty($conf->global->MAIN_PROXY_PORT) ? 0 : $conf->global->MAIN_PROXY_PORT; + $PROXY_USER = empty($conf->global->MAIN_PROXY_USER) ? 0 : $conf->global->MAIN_PROXY_USER; + $PROXY_PASS = empty($conf->global->MAIN_PROXY_PASS) ? 0 : $conf->global->MAIN_PROXY_PASS; dol_syslog("getURLContent postorget=".$postorget." URL=".$url." param=".$param); @@ -54,51 +54,51 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Dolibarr geturl function'); - @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation ?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); - curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it + curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it // By default use tls decied by PHP. // You can force, if supported a version like TLSv1 or TLSv1.2 - if (! empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION); + if (!empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION); //curl_setopt($ch, CURLOPT_SSLVERSION, 6); for tls 1.2 //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?5:$conf->global->MAIN_USE_CONNECT_TIMEOUT); - curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); // PHP 5.5 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // We want response + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // We want response if ($postorget == 'POST') { - curl_setopt($ch, CURLOPT_POST, 1); // POST - curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields + curl_setopt($ch, CURLOPT_POST, 1); // POST + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields } elseif ($postorget == 'POSTALREADYFORMATED') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // HTTP request is 'POST' but param string is taken as it is - curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string } elseif ($postorget == 'PUT') { - $array_param=null; + $array_param = null; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' - if (! is_array($param)) parse_str($param, $array_param); + if (!is_array($param)) parse_str($param, $array_param); else { dol_syslog("parameter param must be a string", LOG_WARNING); - $array_param=$param; + $array_param = $param; } - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields } elseif ($postorget == 'PUTALREADYFORMATED') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' - curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string } elseif ($postorget == 'HEAD') { @@ -107,40 +107,40 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } elseif ($postorget == 'DELETE') { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST } else { - curl_setopt($ch, CURLOPT_POST, 0); // GET + curl_setopt($ch, CURLOPT_POST, 0); // GET } //if USE_PROXY constant set at begin of this method. if ($USE_PROXY) { - dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); + dol_syslog("getURLContent set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS); //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 - curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); - if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); + curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT); + if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); } //getting response from server $response = curl_exec($ch); - $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request + $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request dol_syslog("getURLContent request=".$request); //dol_syslog("getURLContent response =".response); // This may contains binary data, so we dont output it - dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it + dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it - $rep=array(); + $rep = array(); if (curl_errno($ch)) { // Ad keys to $rep - $rep['content']=$response; + $rep['content'] = $response; // moving to display page to display curl errors - $rep['curl_error_no']=curl_errno($ch); - $rep['curl_error_msg']=curl_error($ch); + $rep['curl_error_no'] = curl_errno($ch); + $rep['curl_error_msg'] = curl_error($ch); dol_syslog("getURLContent response array is ".join(',', $rep)); } @@ -155,9 +155,9 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent http_code=".$rep['http_code']); // Add more keys to $rep - $rep['content']=$response; - $rep['curl_error_no']=''; - $rep['curl_error_msg']=''; + $rep['content'] = $response; + $rep['curl_error_no'] = ''; + $rep['curl_error_msg'] = ''; //closing the curl curl_close($ch); @@ -177,19 +177,19 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = */ function getDomainFromURL($url, $mode = 0) { - $tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s):// - $tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain + $tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s):// + $tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain if ($mode == 2) { - $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com' + $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com' } else { - $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com' + $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com' } if (empty($mode)) { - $tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...) + $tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...) } return $tmpdomain; @@ -205,12 +205,12 @@ function getDomainFromURL($url, $mode = 0) */ function getRootURLFromURL($url) { - $prefix=''; + $prefix = ''; $tmpurl = $url; $reg = null; if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) $prefix = $reg[1]; - $tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl); // Remove http(s):// - $tmpurl = preg_replace('/\/.*$/i', '', $tmpurl); // Remove part after domain + $tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl); // Remove http(s):// + $tmpurl = preg_replace('/\/.*$/i', '', $tmpurl); // Remove part after domain return $prefix.$tmpurl; } diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index f1b18df11b2..987895c27d8 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -44,10 +44,10 @@ function holiday_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index b61fba236e2..83eafa2548f 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -36,7 +36,7 @@ function establishment_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -47,7 +47,7 @@ function establishment_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment'); - $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 1e6ebfa6d85..a8469d6bb8b 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -328,7 +328,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) $infoImg = getimagesize($fileSource); // Get image infos $orientation = $exif['Orientation']; - if($orientation != 1){ + if ($orientation != 1) { $img = imagecreatefromjpeg($fileSource); $deg = 0; switch ($orientation) { @@ -413,42 +413,42 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - global $conf,$langs; + global $conf, $langs; dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); // Clean parameters - $file=trim($file); + $file = trim($file); // Check parameters - if (! $file) + if (!$file) { // Si le fichier n'a pas ete indique return 'ErrorBadParameters'; } - elseif (! file_exists($file)) + elseif (!file_exists($file)) { // Si le fichier passe en parametre n'existe pas dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); return $langs->trans("ErrorFileNotFound", $file); } - elseif(image_format_supported($file) < 0) + elseif (image_format_supported($file) < 0) { dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); return 'ErrorBadImageFormat'; } - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { + elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); return 'Error: Wrong value for parameter maxWidth'; } - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { + elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); return 'Error: Wrong value for parameter maxHeight'; } - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image $imgWidth = $infoImg[0]; // Largeur de l'image @@ -462,8 +462,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } } - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged + if ($maxWidth == -1) $maxWidth = $infoImg[0]; // If size is -1, we keep unchanged + if ($maxHeight == -1) $maxHeight = $infoImg[1]; // If size is -1, we keep unchanged // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) @@ -531,7 +531,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', break; } - if (! is_resource($img)) + if (!is_resource($img)) { dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); return 0; @@ -539,7 +539,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $exifAngle = false; if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { - switch($ort) + switch ($ort) { case 3: // 180 rotate left $exifAngle = 180; @@ -563,7 +563,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', { $rotated = false; - if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case { imagealphablending($img, false); imagesavealpha($img, true); diff --git a/htdocs/core/lib/import.lib.php b/htdocs/core/lib/import.lib.php index 32f9d0d87d2..8fa6a995331 100644 --- a/htdocs/core/lib/import.lib.php +++ b/htdocs/core/lib/import.lib.php @@ -36,12 +36,12 @@ function import_prepare_head($param, $maxstep = 0) { global $langs; - if (empty($maxstep)) $maxstep=6; + if (empty($maxstep)) $maxstep = 6; - $h=0; + $h = 0; $head = array(); - $i=1; - while($i <= $maxstep) + $i = 1; + while ($i <= $maxstep) { $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param; $head[$h][1] = $langs->trans("Step")." ".$i; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 15de60eb791..703d50c97f8 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -50,28 +50,28 @@ function facture_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } //if ($fac->mode_reglement_code == 'PRE') - if (! empty($conf->prelevement->enabled)) + if (!empty($conf->prelevement->enabled)) { - $nbStandingOrders=0; + $nbStandingOrders = 0; $sql = "SELECT COUNT(pfd.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " WHERE pfd.fk_facture = ".$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if ($obj) $nbStandingOrders = $obj->nb; } else dol_print_error($db); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id; $head[$h][1] = $langs->trans('StandingOrders'); - if ($nbStandingOrders > 0) $head[$h][1].= ''.$nbStandingOrders.''; + if ($nbStandingOrders > 0) $head[$h][1] .= ''.$nbStandingOrders.''; $head[$h][2] = 'standingorders'; $h++; } @@ -85,23 +85,23 @@ function facture_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index 6e79021e17b..d5ca3431845 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -50,83 +50,83 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = 0, $filesuffix = '', $paymentbankid = '', $thirdpartiesid = '', $fileprefix = 'mergedpdf') { $sql = "SELECT DISTINCT f.rowid, f.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlwhere=''; - $sqlorder=''; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlwhere = ''; + $sqlorder = ''; if (in_array('all', $filter)) { $sqlorder = " ORDER BY f.ref ASC"; } if (in_array('date', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND f.datef >= '".$db->idate($dateafterdate)."'"; - $sqlwhere.= " AND f.datef <= '".$db->idate($datebeforedate)."'"; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= " f.fk_statut > 0"; + $sqlwhere .= " AND f.datef >= '".$db->idate($dateafterdate)."'"; + $sqlwhere .= " AND f.datef <= '".$db->idate($datebeforedate)."'"; $sqlorder = " ORDER BY f.datef ASC"; } if (in_array('nopayment', $filter)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND pf.fk_paiement IS NULL"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= " f.fk_statut > 0"; + $sqlwhere .= " AND pf.fk_paiement IS NULL"; } if (in_array('payments', $filter) || in_array('bank', $filter)) { - $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - if (in_array('bank', $filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND f.rowid = pf.fk_facture"; - $sqlwhere.= " AND pf.fk_paiement = p.rowid"; + $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; + if (in_array('bank', $filter)) $sql .= ", ".MAIN_DB_PREFIX."bank as b"; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= " f.fk_statut > 0"; + $sqlwhere .= " AND f.rowid = pf.fk_facture"; + $sqlwhere .= " AND pf.fk_paiement = p.rowid"; if (in_array('payments', $filter)) { - $sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; - $sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; + $sqlwhere .= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; + $sqlwhere .= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; } if (in_array('bank', $filter)) { - $sqlwhere.= " AND p.fk_bank = b.rowid"; - $sqlwhere.= " AND b.fk_account = ".$paymentbankid; + $sqlwhere .= " AND p.fk_bank = b.rowid"; + $sqlwhere .= " AND b.fk_account = ".$paymentbankid; } $sqlorder = " ORDER BY p.datep ASC"; } if (in_array('nodeposit', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 3'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' type <> 3'; } if (in_array('noreplacement', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 1'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' type <> 1'; } if (in_array('nocreditnote', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 2'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' type <> 2'; } if (in_array('excludethirdparties', $filter) && is_array($thirdpartiesid)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' f.fk_soc NOT IN ('.join(',', $thirdpartiesid).')'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' f.fk_soc NOT IN ('.join(',', $thirdpartiesid).')'; } if (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' f.fk_soc IN ('.join(',', $thirdpartiesid).')'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' f.fk_soc IN ('.join(',', $thirdpartiesid).')'; } - if ($sqlwhere) $sql.=$sqlwhere; - if ($sqlorder) $sql.=$sqlorder; + if ($sqlwhere) $sql .= $sqlwhere; + if ($sqlorder) $sql .= $sqlorder; //print $sql; exit; dol_syslog("scripts/invoices/rebuild_merge.php:", LOG_DEBUG); @@ -138,10 +138,10 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $error = 0; $result = 0; - $files = array() ; // liste les fichiers + $files = array(); // liste les fichiers dol_syslog("scripts/invoices/rebuild_merge.php", LOG_DEBUG); - if ( $resql=$db->query($sql) ) + if ($resql = $db->query($sql)) { $num = $db->num_rows($resql); $cpt = 0; @@ -159,11 +159,11 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $obj = $db->fetch_object($resql); $fac = new Facture($db); - $result=$fac->fetch($obj->rowid); + $result = $fac->fetch($obj->rowid); if ($result > 0) { $outputlangs = $langs; - if (! empty($newlangid)) + if (!empty($newlangid)) { if ($outputlangs->defaultlang != $newlangid) { @@ -171,11 +171,11 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $outputlangs->setDefaultLang($newlangid); } } - $filename=$conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; - if ($regenerate || ! dol_is_file($filename)) + $filename = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; + if ($regenerate || !dol_is_file($filename)) { if ($usestdout) print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n"; - $result= $fac->generateDocument($regenerate?$regenerate:$fac->modelpdf, $outputlangs); + $result = $fac->generateDocument($regenerate ? $regenerate : $fac->modelpdf, $outputlangs); } else { if ($usestdout) print "PDF for invoice ".$obj->ref." already exists\n"; @@ -188,8 +188,8 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte if ($result <= 0) { $error++; - if ($usestdout) print "Error: Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid)."\n"; - else dol_syslog("Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid), LOG_ERR); + if ($usestdout) print "Error: Failed to build PDF for invoice ".($fac->ref ? $fac->ref : ' id '.$obj->rowid)."\n"; + else dol_syslog("Failed to build PDF for invoice ".($fac->ref ? $fac->ref : ' id '.$obj->rowid), LOG_ERR); } $cpt++; @@ -197,10 +197,10 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte // Define format of output PDF - $formatarray=pdf_getFormat($langs); + $formatarray = pdf_getFormat($langs); $page_largeur = $formatarray['width']; $page_hauteur = $formatarray['height']; - $format = array($page_largeur,$page_hauteur); + $format = array($page_largeur, $page_hauteur); if ($usestdout) print "Using output PDF format ".join('x', $format)."\n"; else dol_syslog("Using output PDF format ".join('x', $format), LOG_ERR); @@ -210,7 +210,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte //--------------------------------------------------------- // Create empty PDF - $pdf=pdf_getInstance($format); + $pdf = pdf_getInstance($format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -222,7 +222,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte //$pdf->SetCompression(false); // Add all others - foreach($files as $file) + foreach ($files as $file) { if ($usestdout) print "Merge PDF file for invoice ".$file."\n"; else dol_syslog("Merge PDF file for invoice ".$file); @@ -242,21 +242,21 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte dol_mkdir($diroutputpdf); // Save merged file - $filename=$fileprefix; - if (empty($filename)) $filename='mergedpdf'; - if (! empty($filesuffix)) $filename.='_'.$filesuffix; - $file=$diroutputpdf.'/'.$filename.'.pdf'; + $filename = $fileprefix; + if (empty($filename)) $filename = 'mergedpdf'; + if (!empty($filesuffix)) $filename .= '_'.$filesuffix; + $file = $diroutputpdf.'/'.$filename.'.pdf'; - if (! $error && $pagecount) + if (!$error && $pagecount) { $pdf->Output($file, 'F'); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); } if ($usestdout) { - if (! $error) print "Merged PDF has been built in ".$file."\n"; + if (!$error) print "Merged PDF has been built in ".$file."\n"; else print "Can't build PDF ".$file."\n"; } diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 77b856e2d8e..44ad9cc6ff1 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -23,7 +23,7 @@ * \ingroup core */ -if (! function_exists('json_encode')) +if (!function_exists('json_encode')) { /** * Implement json_encode for PHP that does not have module enabled. @@ -49,14 +49,14 @@ function dol_json_encode($elements) { dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); - $num=0; + $num = 0; if (is_object($elements)) // Count number of properties for an object { - foreach($elements as $key => $value) $num++; + foreach ($elements as $key => $value) $num++; } else { - $num=count($elements); + $num = count($elements); } //var_dump($num); @@ -64,16 +64,16 @@ function dol_json_encode($elements) if (is_numeric(key($elements)) && key($elements) == 0) { // indexed (list) - $keysofelements=array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. + $keysofelements = array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. $output = '['; for ($i = 0, $last = ($num - 1); $i < $num; $i++) { - if (! isset($elements[$keysofelements[$i]])) continue; - if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output.= json_encode($elements[$keysofelements[$i]]); + if (!isset($elements[$keysofelements[$i]])) continue; + if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output .= json_encode($elements[$keysofelements[$i]]); else $output .= _val($elements[$keysofelements[$i]]); - if ($i !== $last) $output.= ','; + if ($i !== $last) $output .= ','; } - $output.= ']'; + $output .= ']'; } else { @@ -81,18 +81,18 @@ function dol_json_encode($elements) $output = '{'; $last = $num - 1; $i = 0; - $tmpelements=array(); - if (is_array($elements)) $tmpelements=$elements; - if (is_object($elements)) $tmpelements=get_object_vars($elements); - foreach($tmpelements as $key => $value) + $tmpelements = array(); + if (is_array($elements)) $tmpelements = $elements; + if (is_object($elements)) $tmpelements = get_object_vars($elements); + foreach ($tmpelements as $key => $value) { $output .= '"'.$key.'":'; - if (is_array($value)) $output.= json_encode($value); + if (is_array($value)) $output .= json_encode($value); else $output .= _val($value); - if ($i !== $last) $output.= ','; + if ($i !== $last) $output .= ','; ++$i; } - $output.= '}'; + $output .= '}'; } // return @@ -204,7 +204,7 @@ function _val($val) else return 'null'; } -if (! function_exists('json_decode')) +if (!function_exists('json_decode')) { /** * Implement json_decode for PHP that does not support it @@ -234,34 +234,34 @@ function dol_json_decode($json, $assoc = false) $comment = false; - $out=''; - $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length - for ($i=0; $i<$strLength; $i++) + $out = ''; + $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length + for ($i = 0; $i < $strLength; $i++) { - if (! $comment) + if (!$comment) { - if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; - elseif (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; - elseif ($json[$i] == ':') $out.= ' => '; - else $out.=$json[$i]; + if (($json[$i] == '{') || ($json[$i] == '[')) $out .= 'array('; + elseif (($json[$i] == '}') || ($json[$i] == ']')) $out .= ')'; + elseif ($json[$i] == ':') $out .= ' => '; + else $out .= $json[$i]; } - else $out.= $json[$i]; - if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; + else $out .= $json[$i]; + if ($json[$i] == '"' && $json[($i - 1)] != "\\") $comment = !$comment; } - $out=_unval($out); + $out = _unval($out); // Return an array if ($out != '') eval('$array = '.$out.';'); - else $array=array(); + else $array = array(); // Return an object - if (! $assoc) + if (!$assoc) { - if (! empty($array)) + if (!empty($array)) { $object = false; - if (count($array)>0) { + if (count($array) > 0) { $object = (object) array(); } foreach ($array as $key => $value) @@ -290,9 +290,9 @@ function _unval($val) while (preg_match('/\\\u([0-9A-F]{2})([0-9A-F]{2})/i', $val, $reg)) { // single, escaped unicode character - $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); + $utf16 = chr(hexdec($reg[1])).chr(hexdec($reg[2])); $utf8 = utf162utf8($utf16); - $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); + $val = preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); } return $val; } @@ -316,7 +316,7 @@ function utf162utf8($utf16) $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]); - switch(true) { + switch (true) { case ((0x7F & $bytes) == $bytes): // this case should never be reached, because we are in ASCII range // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 @@ -357,7 +357,7 @@ function utf82utf16($utf8) return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); } - switch(strlen($utf8)) { + switch (strlen($utf8)) { case 1: // this case should never be reached, because we are in ASCII range // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 @@ -366,12 +366,12 @@ function utf82utf16($utf8) case 2: // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); + return chr(0x07 & (ord($utf8[0]) >> 2)).chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); + return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))).chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); } // ignoring UTF-32 for now, sorry diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index e751dfd68c8..a3c352a0405 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -54,21 +54,21 @@ function loan_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->loan->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; $head[$tab][2] = 'documents'; $tab++; if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); + $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id; $head[$tab][1] = $langs->trans("Notes"); - if($nbNote > 0) $head[$tab][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$tab][1] .= ''.$nbNote.''; $head[$tab][2] = 'note'; $tab++; } diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 1f643dd8a48..d6993845488 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -42,8 +42,8 @@ function member_prepare_head(Adherent $object) $head[$h][2] = 'general'; $h++; - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); @@ -53,13 +53,13 @@ function member_prepare_head(Adherent $object) $h++; } - if (! empty($user->rights->adherent->cotisation->lire)) + if (!empty($user->rights->adherent->cotisation->lire)) { - $nbSubscription = is_array($object->subscriptions)?count($object->subscriptions):0; + $nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0; $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'subscription'; - if ($nbSubscription > 0) $head[$h][1].= ''.$nbSubscription.''; + if ($nbSubscription > 0) $head[$h][1] .= ''.$nbSubscription.''; $h++; } @@ -70,13 +70,13 @@ function member_prepare_head(Adherent $object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'member'); $nbNote = 0; - if(!empty($object->note)) $nbNote++; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $h++; // Attachments @@ -84,22 +84,22 @@ function member_prepare_head(Adherent $object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member'); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; // Show agenda tab - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id; $head[$h][1] = $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -120,7 +120,7 @@ function member_type_prepare_head(AdherentType $object) { global $langs, $conf, $user; - $h=0; + $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id; @@ -129,7 +129,7 @@ function member_type_prepare_head(AdherentType $object) $h++; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id; $head[$h][1] = $langs->trans("Translation"); @@ -137,8 +137,8 @@ function member_type_prepare_head(AdherentType $object) $h++; } - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 22e660b2e22..ba1ed6bb8a0 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -21,14 +21,14 @@ * \brief Set of function for memory/cache management */ -global $shmkeys,$shmoffset; +global $shmkeys, $shmoffset; -$shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6, - 'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12, - 'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19, - 'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24, - 'donations'=>25,'contracts'=>26); -$shmoffset=1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. +$shmkeys = array('main'=>1, 'admin'=>2, 'dict'=>3, 'companies'=>4, 'suppliers'=>5, 'products'=>6, + 'commercial'=>7, 'compta'=>8, 'projects'=>9, 'cashdesk'=>10, 'agenda'=>11, 'bills'=>12, + 'propal'=>13, 'boxes'=>14, 'banks'=>15, 'other'=>16, 'errors'=>17, 'members'=>18, 'ecm'=>19, + 'orders'=>20, 'users'=>21, 'help'=>22, 'stocks'=>23, 'interventions'=>24, + 'donations'=>25, 'contracts'=>26); +$shmoffset = 1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. @@ -95,7 +95,7 @@ function dol_setcache($memoryid, $data) // Using shmop elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $result=dol_setshmop($memoryid, $data); + $result = dol_setshmop($memoryid, $data); } return $result; @@ -167,7 +167,7 @@ function dol_getcache($memoryid) // Using shmop elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $data=dol_getshmop($memoryid); + $data = dol_getshmop($memoryid); return $data; } @@ -184,9 +184,9 @@ function dol_getcache($memoryid) */ function dol_getshmopaddress($memoryid) { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; if (empty($shmkeys[$memoryid])) return 0; - return $shmkeys[$memoryid]+$shmoffset; + return $shmkeys[$memoryid] + $shmoffset; } /** @@ -196,13 +196,13 @@ function dol_getshmopaddress($memoryid) */ function dol_listshmop() { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; - $resarray=array(); - foreach($shmkeys as $key => $val) + $resarray = array(); + foreach ($shmkeys as $key => $val) { - $result=dol_getshmop($key); - if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; + $result = dol_getshmop($key); + if (!is_numeric($result) || $result > 0) $resarray[$key] = $result; } return $resarray; } @@ -216,25 +216,25 @@ function dol_listshmop() */ function dol_setshmop($memoryid, $data) { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; //print 'dol_setshmop memoryid='.$memoryid."
\n"; - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; - $shmkey=dol_getshmopaddress($memoryid); - $newdata=serialize($data); - $size=strlen($newdata); + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0; + $shmkey = dol_getshmopaddress($memoryid); + $newdata = serialize($data); + $size = strlen($newdata); //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes
\n"; - $handle=shmop_open($shmkey, 'c', 0644, 6+$size); + $handle = shmop_open($shmkey, 'c', 0644, 6 + $size); if ($handle) { - $shm_bytes_written1=shmop_write($handle, str_pad($size, 6), 0); - $shm_bytes_written2=shmop_write($handle, $newdata, 6); - if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata))) + $shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0); + $shm_bytes_written2 = shmop_write($handle, $newdata, 6); + if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata))) { print "Couldn't write the entire length of data\n"; } shmop_close($handle); - return ($shm_bytes_written1+$shm_bytes_written2); + return ($shm_bytes_written1 + $shm_bytes_written2); } else { @@ -251,16 +251,16 @@ function dol_setshmop($memoryid, $data) */ function dol_getshmop($memoryid) { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; - $shmkey=dol_getshmopaddress($memoryid); + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) return 0; + $shmkey = dol_getshmopaddress($memoryid); //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."
\n"; - $handle=@shmop_open($shmkey, 'a', 0, 0); + $handle = @shmop_open($shmkey, 'a', 0, 0); if ($handle) { - $size=trim(shmop_read($handle, 0, 6)); - if ($size) $data=unserialize(shmop_read($handle, 6, $size)); + $size = trim(shmop_read($handle, 0, 6)); + if ($size) $data = unserialize(shmop_read($handle, 6, $size)); else return -1; shmop_close($handle); } diff --git a/htdocs/core/lib/multicurrency.lib.php b/htdocs/core/lib/multicurrency.lib.php index f17d79c6207..85142e0e631 100644 --- a/htdocs/core/lib/multicurrency.lib.php +++ b/htdocs/core/lib/multicurrency.lib.php @@ -55,10 +55,10 @@ function multicurrencyLimitPrepareHead($aCurrencies) { global $langs; - $i=0; + $i = 0; $head = array(); - foreach($aCurrencies as $currency) + foreach ($aCurrencies as $currency) { $head[$i][0] = $_SERVER['PHP_SELF'].'?currencycode='.$currency; $head[$i][1] = $langs->trans("Currency".$currency).' ('.$langs->getCurrencySymbol($currency).')'; diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index eb1a5495a95..34e1d99bd80 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -24,20 +24,20 @@ // Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) -$supportedoauth2array=array( +$supportedoauth2array = array( 'OAUTH_GOOGLE_NAME'=>'google', ); if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME']='stripetest'; - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME']='stripelive'; + $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = 'stripetest'; + $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = 'stripelive'; } -$supportedoauth2array['OAUTH_GITHUB_NAME']='github'; +$supportedoauth2array['OAUTH_GITHUB_NAME'] = 'github'; // API access parameters OAUTH -$list = array ( +$list = array( array( 'OAUTH_AMAZON_NAME', 'OAUTH_AMAZON_ID', diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 54d850d99b6..3d2847e926b 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -53,7 +53,7 @@ function commande_prepare_head(Commande $object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -61,16 +61,16 @@ function commande_prepare_head(Commande $object) if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) { - $nbShipments=$object->getNbOfShipments(); $nbReceiption=0; + $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; - $text=''; - if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments"); - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; - if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings"); - if ($nbShipments > 0 || $nbReceiption > 0) $text.= ''.($nbShipments?$nbShipments:0); - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.='/'; - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0); - if ($nbShipments > 0 || $nbReceiption > 0) $text.= ''; + $text = ''; + if ($conf->expedition_bon->enabled) $text .= $langs->trans("Shipments"); + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text .= '/'; + if ($conf->livraison_bon->enabled) $text .= $langs->trans("Receivings"); + if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''.($nbShipments ? $nbShipments : 0); + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= '/'; + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ($nbReceiption ? $nbReceiption : 0); + if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''; $head[$h][1] = $text; $head[$h][2] = 'shipping'; $h++; @@ -85,23 +85,23 @@ function commande_prepare_head(Commande $object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/parsemd.lib.php b/htdocs/core/lib/parsemd.lib.php index 280e77dcc9c..7dfd025609c 100644 --- a/htdocs/core/lib/parsemd.lib.php +++ b/htdocs/core/lib/parsemd.lib.php @@ -33,7 +33,7 @@ function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null) { if (is_array($replaceimagepath)) { - foreach($replaceimagepath as $key => $val) + foreach ($replaceimagepath as $key => $val) { $keytoreplace = ']('.$key; $valafter = ']('.$val; @@ -67,7 +67,7 @@ function dolMd2Asciidoc($content, $parser = 'dolibarr', $replaceimagepath = null { if (is_array($replaceimagepath)) { - foreach($replaceimagepath as $key => $val) + foreach ($replaceimagepath as $key => $val) { $keytoreplace = ']('.$key; $valafter = ']('.$val; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index e7a9bd51034..80aed36f674 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -99,22 +99,22 @@ function getValidOnlinePaymentMethods($paymentmethod = '') { global $conf, $langs; - $validpaymentmethod=array(); + $validpaymentmethod = array(); - if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) + if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { $langs->load("paypal"); - $validpaymentmethod['paypal']='valid'; + $validpaymentmethod['paypal'] = 'valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { $langs->load("paybox"); - $validpaymentmethod['paybox']='valid'; + $validpaymentmethod['paybox'] = 'valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) + if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) { $langs->load("stripe"); - $validpaymentmethod['stripe']='valid'; + $validpaymentmethod['stripe'] = 'valid'; } // TODO Add trigger @@ -173,107 +173,107 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag if ($type == 'free') { - $out=$urltouse.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; - else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } //if ($mode) $out.='&noidempotency=1'; } elseif ($type == 'order') { - $out=$urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); - if ($mode == 1) $out.='order_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'order_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } elseif ($type == 'invoice') { - $out=$urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); - if ($mode == 1) $out.='invoice_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'invoice_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } elseif ($type == 'contractline') { - $out=$urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); - if ($mode == 1) $out.='contractline_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'contractline_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } elseif ($type == 'member' || $type == 'membersubscription') { - $out=$urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); - if ($mode == 1) $out.='member_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'member_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'donation') { - $out=$urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); - if ($mode == 1) $out.='donation_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'donation_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } // For multicompany - if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities + if (!empty($out) && !empty($conf->multicompany->enabled)) $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities return $out; } diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php index 035f0adb754..eca43aef3f6 100644 --- a/htdocs/core/lib/prelevement.lib.php +++ b/htdocs/core/lib/prelevement.lib.php @@ -78,8 +78,8 @@ function prelevement_prepare_head(BonPrelevement $object) function prelevement_check_config() { global $conf; - if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1; - if(empty($conf->global->PRELEVEMENT_ICS)) return -1; - if(empty($conf->global->PRELEVEMENT_USER)) return -1; + if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1; + if (empty($conf->global->PRELEVEMENT_ICS)) return -1; + if (empty($conf->global->PRELEVEMENT_USER)) return -1; return 0; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9b9f000cf17..428d976ab6d 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -487,10 +487,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Ref of task - if (count($arrayfields)>0 && !empty($arrayfields['t.ref']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.ref']['checked'])) { print ''; if ($showlineingray) { - print '' . img_object('', 'projecttask') . ' ' . $lines[$i]->ref . ''; + print ''.img_object('', 'projecttask').' '.$lines[$i]->ref.''; } else { print $taskstatic->getNomUrl(1, 'withproject'); } @@ -498,7 +498,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Title of task - if (count($arrayfields)>0 && !empty($arrayfields['t.label']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) { print ""; if ($showlineingray) print ''; @@ -516,21 +516,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "\n"; } - if (count($arrayfields)>0 && !empty($arrayfields['t.description']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) { print ""; print $lines[$i]->description; print "\n"; } // Date start - if (count($arrayfields)>0 && !empty($arrayfields['t.dateo']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) { print ''; print dol_print_date($lines[$i]->date_start, 'dayhour'); print ''; } // Date end - if (count($arrayfields)>0 && !empty($arrayfields['t.datee']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) { print ''; print dol_print_date($lines[$i]->date_end, 'dayhour'); if ($taskstatic->hasDelay()) @@ -544,7 +544,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) - if (count($arrayfields)>0 && !empty($arrayfields['t.planned_workload']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) { print ''; $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks @@ -558,11 +558,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Time spent - if (count($arrayfields)>0 && !empty($arrayfields['t.duration_effective']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) { print ''; if ($showlineingray) print ''; - else print ''; + else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); else print '--:--'; @@ -573,18 +573,18 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Progress calculated (Note: ->duration is time spent) - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_calculated']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { print ''; if ($lines[$i]->planned_workload || $lines[$i]->duration) { if ($lines[$i]->planned_workload) - print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2) . ' %'; - else print '' . $langs->trans('WorkloadNotDefined') . ''; + print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; + else print ''.$langs->trans('WorkloadNotDefined').''; } print ''; } // Progress declared - if (count($arrayfields)>0 && !empty($arrayfields['t.progress']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) { print ''; if ($lines[$i]->progress != '') { print getTaskProgressBadge($taskstatic); @@ -593,7 +593,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // resume - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_summary']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) { print ''; if ($lines[$i]->progress != '' && $lines[$i]->duration) { print getTaskProgressView($taskstatic, false, false); @@ -604,25 +604,25 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($showbilltime) { // Time not billed - if (count($arrayfields)>0 && !empty($arrayfields['t.tobill']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) { print ''; if ($lines[$i]->usage_bill_time) { print convertSecondToTime($lines[$i]->tobill, 'allhourmin'); $total_projectlinesa_tobill += $lines[$i]->tobill; } else { - print '' . $langs->trans("NA") . ''; + print ''.$langs->trans("NA").''; } print ''; } // Time billed - if (count($arrayfields)>0 && !empty($arrayfields['t.billed']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) { print ''; if ($lines[$i]->usage_bill_time) { print convertSecondToTime($lines[$i]->billed, 'allhourmin'); $total_projectlinesa_billed += $lines[$i]->billed; } else { - print '' . $langs->trans("NA") . ''; + print ''.$langs->trans("NA").''; } print ''; } @@ -650,12 +650,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Extra fields - $extrafieldsobjectkey=$taskstatic->table_element; - $obj=$lines[$i]; + $extrafieldsobjectkey = $taskstatic->table_element; + $obj = $lines[$i]; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$lines[$i]); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$lines[$i]); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Tick to drag and drop @@ -693,18 +693,18 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; print ''.$langs->trans("Total").''; if ($showproject) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.label']['checked'])) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.dateo']['checked'])) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.datee']['checked'])) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.planned_workload']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) print ''; + if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) print ''; + if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) print ''; + if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; } - if (count($arrayfields)>0 && !empty($arrayfields['t.duration_effective']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) { print ''; if ($projectidfortotallink > 0) - print ''; + print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; @@ -734,27 +734,27 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_calculated']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { print ''; if ($total_projectlinesa_planned) - print $totalCalculatedProgress . ' %'; + print $totalCalculatedProgress.' %'; print ''; } - if (count($arrayfields)>0 && !empty($arrayfields['t.progress']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) { print ''; if ($total_projectlinesa_planned) - print '' . $totalAverageDeclaredProgress . ' %'; + print ''.$totalAverageDeclaredProgress.' %'; print ''; } // resume - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_summary']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) { print ''; if ($total_projectlinesa_planned) { print ''; - print '
'; - print '
'; + print '
'; + print '
'; print '
'; print '
'; } @@ -763,12 +763,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($showbilltime) { - if (count($arrayfields)>0 && !empty($arrayfields['t.tobill']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin'); print ''; } - if (count($arrayfields)>0 && !empty($arrayfields['t.billed']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_billed, 'allhourmin'); print ''; @@ -2073,7 +2073,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $listofstatus = array_keys($listofoppstatus); - if (is_array($listofstatus) && ! empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) { + if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) { // Define $themeColorId and array $statusOppList for each $listofstatus $themeColorId = 0; $statusOppList = array(); @@ -2216,7 +2216,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if ($userAccess >= 0) { $projectstatic->ref = $objp->ref; - $projectstatic->statut = $objp->status; // deprecated + $projectstatic->statut = $objp->status; // deprecated $projectstatic->status = $objp->status; $projectstatic->title = $objp->title; $projectstatic->datee = $db->jdate($objp->datee); diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 9e12e9d4229..fcdf4bbb79d 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -42,14 +42,14 @@ function propal_prepare_head($object) $head[$h][2] = 'comm'; $h++; - if ((empty($conf->commande->enabled) && ((! empty($conf->expedition->enabled) && ! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) - || (! empty($conf->expedition->enabled) && ! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) + if ((empty($conf->commande->enabled) && ((!empty($conf->expedition->enabled) && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) + || (!empty($conf->expedition->enabled) && !empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) { $langs->load("sendings"); $text = ''; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; - if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); - if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); + if ($conf->expedition_bon->enabled) $text = $langs->trans("Shipment"); + if ($conf->livraison_bon->enabled) $text .= '/'.$langs->trans("Receivings"); $head[$h][1] = $text; $head[$h][2] = 'shipping'; $h++; @@ -60,7 +60,7 @@ function propal_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -74,23 +74,23 @@ function propal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index 33591b3beea..3cf9a535eaa 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -60,7 +60,7 @@ function reception_prepare_head(Reception $object) $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -70,7 +70,7 @@ function reception_prepare_head(Reception $object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; @@ -103,7 +103,7 @@ function reception_admin_prepare_head() $h++; - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -111,7 +111,7 @@ function reception_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 979583e8b4d..5a8d5d2530e 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -44,11 +44,11 @@ function report_header($reportname, $notused, $period, $periodlink, $description print "\n\n\n"; - if(! empty($varlink)) $varlink = '?'.$varlink; + if (!empty($varlink)) $varlink = '?'.$varlink; $head = array(); - $h=0; + $h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("Report"); $head[$h][2] = 'report'; @@ -58,7 +58,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description dol_fiche_head($head, 'report'); - foreach($moreparam as $key => $value) + foreach ($moreparam as $key => $value) { print ''."\n"; } diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index 7bd2454dbe6..e6a0998ba6f 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -45,7 +45,7 @@ function resource_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -59,30 +59,30 @@ function resource_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->resource->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if($nbFiles > 0) $head[$h][1].= ''.$nbFiles.''; + if ($nbFiles > 0) $head[$h][1] .= ''.$nbFiles.''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index 01b3cafd60d..0e2328bc7e7 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -46,12 +46,12 @@ function salaries_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b9a606b98b4..04d16084365 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -221,7 +221,7 @@ if (!function_exists('dol_loginfunction')) // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; - $urllogo=DOL_URL_ROOT.'/theme/common/login_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 7f8de19e2e5..34dd845cdfa 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -37,7 +37,7 @@ function shipping_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("sendings","deliveries")); + $langs->loadLangs(array("sendings", "deliveries")); $h = 0; $head = array(); @@ -74,19 +74,19 @@ function shipping_prepare_head($object) $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -95,7 +95,7 @@ function shipping_prepare_head($object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; @@ -122,7 +122,7 @@ function delivery_prepare_head($object) global $langs, $db, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("sendings","deliveries")); + $langs->loadLangs(array("sendings", "deliveries")); $h = 0; $head = array(); @@ -165,12 +165,12 @@ function delivery_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($tmpobject->ref); + $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($tmpobject->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $tmpobject->element, $tmpobject->id); + $nbLinks = Link::count($db, $tmpobject->element, $tmpobject->id); $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$tmpobject->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -179,7 +179,7 @@ function delivery_prepare_head($object) if (!empty($tmpobject->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$tmpobject->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; @@ -206,29 +206,29 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') global $db, $conf, $langs; global $form; - $product_static=new Product($db); - $expedition=new Expedition($db); - $warehousestatic=new Entrepot($db); + $product_static = new Product($db); + $expedition = new Expedition($db); + $warehousestatic = new Entrepot($db); $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; - $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; - $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; + $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; + $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; - $sql.= ' p.description as product_desc'; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; + $sql .= ' p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; //TODO Add link to expeditiondet_batch - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; - $sql.= " AND obj.fk_".$origin." = ".$origin_id; - $sql.= " AND obj.rowid = ed.fk_origin_line"; - $sql.= " AND ed.fk_expedition = e.rowid"; - if ($filter) $sql.= $filter; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sql .= " AND obj.fk_".$origin." = ".$origin_id; + $sql .= " AND obj.rowid = ed.fk_origin_line"; + $sql .= " AND ed.fk_expedition = e.rowid"; + if ($filter) $sql .= $filter; - $sql.= " ORDER BY obj.fk_product"; + $sql .= " ORDER BY obj.fk_product"; dol_syslog("show_list_sending_receive", LOG_DEBUG); $resql = $db->query($sql); @@ -250,7 +250,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$langs->trans("DateCreation").''; print ''.$langs->trans("DateDeliveryPlanned").''; print ''.$langs->trans("QtyPreparedOrShipped").''; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''.$langs->trans("Warehouse").''; } @@ -260,7 +260,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; print ''; }*/ - if (! empty($conf->livraison_bon->enabled)) + if (!empty($conf->livraison_bon->enabled)) { print ''.$langs->trans("DeliveryOrder").''; //print ''.$langs->trans("QtyReceived").''; @@ -283,52 +283,52 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') if ($objp->fk_product > 0) { // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object = new $origin($db); $object->fetch($origin_id); $object->fetch_thirdparty(); $prod = new Product($db); - $prod->id=$objp->fk_product; + $prod->id = $objp->fk_product; $prod->getMultiLangs(); $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + if (empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; } else { - $label = (! empty($objp->label)?$objp->label:$objp->product_label); + $label = (!empty($objp->label) ? $objp->label : $objp->product_label); } print ''; // Show product and description - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->fk_product; - $product_static->ref=$objp->ref; - $product_static->status_batch=$objp->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); + $product_static->type = $objp->fk_product_type; + $product_static->id = $objp->fk_product; + $product_static->ref = $objp->ref; + $product_static->status_batch = $objp->product_tobatch; + $text = $product_static->getNomUrl(1); + $text .= ' - '.$label; + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($objp->date_start, $objp->date_end); // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (! empty($objp->description) && $objp->description!=$objp->product)?'
'.dol_htmlentitiesbr($objp->description):''; + print (!empty($objp->description) && $objp->description != $objp->product) ? '
'.dol_htmlentitiesbr($objp->description) : ''; } print ''; @@ -336,11 +336,11 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') else { print ""; - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'), 'service'); + if ($objp->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($objp->label)) { - $text.= ' '.$objp->label.''; + if (!empty($objp->label)) { + $text .= ' '.$objp->label.''; print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); } else { print $text.' '.nl2br($objp->description); @@ -363,7 +363,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$objp->qty_shipped.''; // Warehouse - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''; if ($objp->warehouse_id > 0) @@ -407,17 +407,17 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') }*/ // Informations on receipt - if (! empty($conf->livraison_bon->enabled)) + if (!empty($conf->livraison_bon->enabled)) { include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; - $expedition->id=$objp->sendingid; + $expedition->id = $objp->sendingid; $expedition->fetchObjectLinked($expedition->id, $expedition->element); //var_dump($expedition->linkedObjects); - $receiving=''; - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link + $receiving = ''; + if (count($expedition->linkedObjects['delivery']) > 0) $receiving = reset($expedition->linkedObjects['delivery']); // Take first link - if (! empty($receiving)) + if (!empty($receiving)) { // $expedition->fk_origin_line = id of det line of order // $receiving->fk_origin_line = id of det line of order diff --git a/htdocs/core/lib/supplier_proposal.lib.php b/htdocs/core/lib/supplier_proposal.lib.php index 6549b362c11..ddc85616ba6 100644 --- a/htdocs/core/lib/supplier_proposal.lib.php +++ b/htdocs/core/lib/supplier_proposal.lib.php @@ -34,7 +34,7 @@ function supplier_proposal_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("supplier_proposal","compta")); + $langs->loadLangs(array("supplier_proposal", "compta")); $h = 0; $head = array(); @@ -49,7 +49,7 @@ function supplier_proposal_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -63,23 +63,23 @@ function supplier_proposal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index 6cf8189f3c8..8a883ceef91 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -47,7 +47,7 @@ function takepos_prepare_head() for ($i = 1; $i <= $numterminals; $i++) { $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i; - $head[$h][1] = $langs->trans("Terminal"). " ".$i; + $head[$h][1] = $langs->trans("Terminal")." ".$i; $head[$h][2] = 'terminal'.$i; $h++; } diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index ade6a7f49cf..cdf9fe29b1c 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -54,12 +54,12 @@ function tax_prepare_head(ChargeSociales $object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->tax->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -93,131 +93,131 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di global $conf; // If we use date_start and date_end, we must not use $y, $m, $q - if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + if (($date_start || $date_end) && (!empty($y) || !empty($m) || !empty($q))) { dol_print_error('', 'Bad value of input parameter for tax_by_rate'); } - $list=array(); + $list = array(); if ($direction == 'sell') { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='ref'; + $invoicetable = 'facture'; + $invoicedettable = 'facturedet'; + $fk_facture = 'fk_facture'; + $fk_facture2 = 'fk_facture'; + $fk_payment = 'fk_paiement'; + $total_tva = 'total_tva'; + $paymenttable = 'paiement'; + $paymentfacturetable = 'paiement_facture'; + $invoicefieldref = 'ref'; } elseif ($direction == 'buy') { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; + $invoicetable = 'facture_fourn'; + $invoicedettable = 'facture_fourn_det'; + $fk_facture = 'fk_facture_fourn'; + $fk_facture2 = 'fk_facturefourn'; + $fk_payment = 'fk_paiementfourn'; + $total_tva = 'tva'; + $paymenttable = 'paiementfourn'; + $paymentfacturetable = 'paiementfourn_facturefourn'; + $invoicefieldref = 'ref'; } if (strpos($type, 'localtax') === 0) { - $f_rate = $type . '_tx'; + $f_rate = $type.'_tx'; } else { $f_rate = 'tva_tx'; } - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; + $total_localtax1 = 'total_localtax1'; + $total_localtax2 = 'total_localtax2'; // CAS DES BIENS/PRODUITS // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) return -1; + if (!$sql) return -1; if ($sql == 'TODO') return -2; if ($sql != 'TODO') { @@ -227,17 +227,17 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($resql) { $company_id = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; @@ -262,7 +262,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['totalht_list'][] = $assoc['total_ht']; $list[$assoc['company_id']]['vat_list'][] = $assoc['total_vat']; $list[$assoc['company_id']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; + $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; $list[$assoc['company_id']]['pid'][] = $assoc['pid']; $list[$assoc['company_id']]['pref'][] = $assoc['pref']; @@ -285,90 +285,90 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // CAS DES SERVICES // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { // Count on invoice date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -378,17 +378,17 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($resql) { $company_id = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; @@ -438,40 +438,40 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($direction == 'buy') // buy only for expense reports { // Define sql request - $sql=''; + $sql = ''; // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; - $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; - $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; - $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; - $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; - $sql.= " WHERE e.entity = " . $conf->entity; - $sql.= " AND e.fk_statut in (6)"; + $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; + $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; + $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; + $sql .= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; + $sql .= " WHERE e.entity = ".$conf->entity; + $sql .= " AND e.fk_statut in (6)"; if ($y && $m) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = -1"; - $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; - $sql.= " ORDER BY e.rowid"; + if ($q) $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = -1"; + $sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + $sql .= " ORDER BY e.rowid"; - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -481,18 +481,18 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($resql) { $company_id = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; - $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; + $oldrowid = $assoc['rowid']; + $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; @@ -561,132 +561,132 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire global $conf; // If we use date_start and date_end, we must not use $y, $m, $q - if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + if (($date_start || $date_end) && (!empty($y) || !empty($m) || !empty($q))) { dol_print_error('', 'Bad value of input parameter for tax_by_rate'); } - $list=array(); + $list = array(); if ($direction == 'sell') { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='ref'; + $invoicetable = 'facture'; + $invoicedettable = 'facturedet'; + $fk_facture = 'fk_facture'; + $fk_facture2 = 'fk_facture'; + $fk_payment = 'fk_paiement'; + $total_tva = 'total_tva'; + $paymenttable = 'paiement'; + $paymentfacturetable = 'paiement_facture'; + $invoicefieldref = 'ref'; } else { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; + $invoicetable = 'facture_fourn'; + $invoicedettable = 'facture_fourn_det'; + $fk_facture = 'fk_facture_fourn'; + $fk_facture2 = 'fk_facturefourn'; + $fk_payment = 'fk_paiementfourn'; + $total_tva = 'tva'; + $paymenttable = 'paiementfourn'; + $paymentfacturetable = 'paiementfourn_facturefourn'; + $invoicefieldref = 'ref'; } - if ( strpos($type, 'localtax') === 0 ) { - $f_rate = $type . '_tx'; + if (strpos($type, 'localtax') === 0) { + $f_rate = $type.'_tx'; } else { $f_rate = 'tva_tx'; } - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; + $total_localtax1 = 'total_localtax1'; + $total_localtax2 = 'total_localtax2'; // CAS DES BIENS/PRODUITS // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) return -1; + if (!$sql) return -1; if ($sql == 'TODO') return -2; if ($sql != 'TODO') { @@ -696,18 +696,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($resql) { $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { // Code to avoid warnings when array entry not defined - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; @@ -754,90 +754,90 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // CAS DES SERVICES // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { // Count on invoice date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -847,18 +847,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($resql) { $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { // Code to avoid warnings when array entry not defined - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; @@ -907,40 +907,40 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($direction == 'buy') // buy only for expense reports { // Define sql request - $sql=''; + $sql = ''; // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; - $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; - $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; - $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; - $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; - $sql.= " WHERE e.entity = " . $conf->entity; - $sql.= " AND e.fk_statut in (6)"; + $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; + $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; + $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; + $sql .= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; + $sql .= " WHERE e.entity = ".$conf->entity; + $sql .= " AND e.fk_statut in (6)"; if ($y && $m) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = -1"; - $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; - $sql.= " ORDER BY e.rowid"; + if ($q) $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = -1"; + $sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + $sql .= " ORDER BY e.rowid"; - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -950,20 +950,20 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($resql) { $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { // Code to avoid warnings when array entry not defined - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index fe7fb4ba5a7..e12531b3846 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -87,7 +87,7 @@ function ticket_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -95,13 +95,13 @@ function ticket_prepare_head($object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); // Attached files - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $upload_dir = $conf->ticket->dir_output . "/" . $object->ref; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->ticket->dir_output."/".$object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files')); - $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?id=' . $object->id; + $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); if ($nbFiles > 0) { - $head[$h][1] .= '' . $nbFiles . ''; + $head[$h][1] .= ''.$nbFiles.''; } $head[$h][2] = 'tabTicketDocument'; @@ -218,39 +218,39 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $width = 0; - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { // Print logo - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) + if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { - $urllogo = DOL_URL_ROOT . '/theme/common/login_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); $width = 150; - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$mysoc->logo); $width = 150; - } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { - $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; + } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) { + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } } } print '
'; // Output html code for logo - if ($urllogo || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) + if ($urllogo || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { print '
'; print '
'; if ($urllogo) { - print ''; + print ''; print ''; print ''; } - if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { - print '
' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ''; + if (!empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + print '
'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).''; } print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { @@ -721,64 +721,64 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($user->rights->agenda->allactions->create || (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - $out.=''; + $out .= ''; } - $out.=''; + $out .= ''; // Date - $out.=' '; - $out.=dol_print_date($histo[$key]['datestart'], 'dayhour'); + $out .= ' '; + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { - $tmpa=dol_getdate($histo[$key]['datestart'], true); - $tmpb=dol_getdate($histo[$key]['dateend'], true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'], 'hour'); - else $out.='-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); + $tmpa = dol_getdate($histo[$key]['datestart'], true); + $tmpb = dol_getdate($histo[$key]['dateend'], true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour'); + else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); } - $late=0; - if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($late) $out.=img_warning($langs->trans("Late")).' '; - $out.="\n"; + $late = 0; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($late) $out .= img_warning($langs->trans("Late")).' '; + $out .= "\n"; // Ref - $out.='

'; + $out .= '

'; // Author of event - $out.=''; + $out .= ''; if ($histo[$key]['userid'] > 0) { - if(!isset($userGetNomUrlCache[$histo[$key]['userid']])){ // is in cache ? + if (!isset($userGetNomUrlCache[$histo[$key]['userid']])) { // is in cache ? $userstatic->fetch($histo[$key]['userid']); $userGetNomUrlCache[$histo[$key]['userid']] = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } - $out.= $userGetNomUrlCache[$histo[$key]['userid']]; + $out .= $userGetNomUrlCache[$histo[$key]['userid']]; } - $out.=''; + $out .= ''; // Title $out .= ' '; - if($actionstatic->code == 'TICKET_MSG') { + if ($actionstatic->code == 'TICKET_MSG') { $out .= $langs->trans('TicketNewMessage'); } - elseif($actionstatic->code == 'TICKET_MSG_PRIVATE') { + elseif ($actionstatic->code == 'TICKET_MSG_PRIVATE') { $out .= $langs->trans('TicketNewMessage').' ('.$langs->trans('Private').')'; - }else{ + } else { if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { - $transcode = $langs->trans("Action" . $histo[$key]['acode']); - $libelle = ($transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); $libelle = $histo[$key]['note']; $actionstatic->id = $histo[$key]['id']; $out .= dol_trunc($libelle, 120); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out .= '' . img_object($langs->trans("ShowEMailing"), "email") . ' '; - $transcode = $langs->trans("Action" . $histo[$key]['acode']); - $libelle = ($transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); $out .= dol_trunc($libelle, 120); } } @@ -835,25 +835,25 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($result > 0) { $footer .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $footer .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $footer .= '('.dol_print_phone($contact->phone_pro).')'; } } } - $documents = getTicketActionCommEcmList($actionstatic) ; - if(!empty($documents)) + $documents = getTicketActionCommEcmList($actionstatic); + if (!empty($documents)) { - $footer.= ''; } @@ -881,19 +881,19 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no - if(!empty($footer)){ - $out.=''; + if (!empty($footer)) { + $out .= ''; } - $out.='

'."\n"; // end timeline-item + $out .= '
'."\n"; // end timeline-item - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; $i++; } - $out.="\n"; + $out .= "\n"; } @@ -915,12 +915,12 @@ function getTicketActionCommEcmList($object) $documents = array(); $sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; - $sql.= ' WHERE ecm.filepath = \'agenda/'.$object->id.'\''; + $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; + $sql .= ' WHERE ecm.filepath = \'agenda/'.$object->id.'\''; //$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type - $sql.= ' ORDER BY ecm.position ASC'; + $sql .= ' ORDER BY ecm.position ASC'; - $resql= $db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql)) { while ($obj = $db->fetch_object($resql)) { diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index cb4088c6bf2..0dcb6e8242d 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -35,19 +35,19 @@ */ function tree_showpad(&$fulltree, $key, $silent = 0) { - $pos=1; + $pos = 1; // Loop on each pos, because we will output an img for each pos while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) { // Process for column $pos - $atleastoneofthislevelafter=0; - $nbofdirinsub=0; - $nbofdocinsub=0; - $found=0; + $atleastoneofthislevelafter = 0; + $nbofdirinsub = 0; + $nbofdocinsub = 0; + $found = 0; //print 'x'.$key; - foreach($fulltree as $key2 => $val2) + foreach ($fulltree as $key2 => $val2) { //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; if ($found == 1) // We are after the entry to show @@ -55,11 +55,11 @@ function tree_showpad(&$fulltree, $key, $silent = 0) if ($fulltree[$key2]['level'] > $pos) { $nbofdirinsub++; - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub += $fulltree[$key2]['cachenbofdoc']; } if ($fulltree[$key2]['level'] == $pos) { - $atleastoneofthislevelafter=1; + $atleastoneofthislevelafter = 1; } if ($fulltree[$key2]['level'] <= $pos) { @@ -68,12 +68,12 @@ function tree_showpad(&$fulltree, $key, $silent = 0) } if ($key2 == $key) // We found ourself, so now every lower level will be counted { - $found=1; + $found = 1; } } //print $atleastoneofthislevelafter; - if (! $silent) + if (!$silent) { if ($atleastoneofthislevelafter) { @@ -89,7 +89,7 @@ function tree_showpad(&$fulltree, $key, $silent = 0) $pos++; } - return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); + return array($atleastoneofthislevelafter, $nbofdirinsub, $nbofdocinsub); } @@ -117,7 +117,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset { global $tree_recur_alreadyadded, $menu_handler_to_search; - if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); + if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded = array(); if ($rang == 0) { @@ -141,30 +141,30 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset if ($rang > 50) { - return; // Protect against infinite loop. Max 50 depth + return; // Protect against infinite loop. Max 50 depth } //ballayage du tableau - $sizeoftab=count($tab); - $ulprinted=0; - for ($x=0; $x < $sizeoftab; $x++) + $sizeoftab = count($tab); + $ulprinted = 0; + for ($x = 0; $x < $sizeoftab; $x++) { //var_dump($tab[$x]);exit; // If an element has $pere for parent if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) { //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."
\n"; - if (empty($ulprinted) && ! empty($pere['rowid'])) + if (empty($ulprinted) && !empty($pere['rowid'])) { - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) { dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); continue; } - print ''; $ulprinted++; + print ''; $ulprinted++; } - print "\n".'
  • '; + print "\n".'
  • '; if ($showfk) { print ''; // Year print ''; @@ -251,11 +251,11 @@ print ''; print '';*/ print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while (! empty($year) && $oldyear > $year+1) + while (!empty($year) && $oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; @@ -273,7 +273,7 @@ foreach ($data as $val) /*print ''; print '';*/ print ''; - $oldyear=$year; + $oldyear = $year; } print '
    '; @@ -180,26 +180,26 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset print $tab[$x]['entry']; } //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
    '."\n"; - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); // And now we search all its sons of lower level - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); print ''; } - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) + elseif (!empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) { //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."
    \n"; - if (empty($ulprinted) && ! empty($pere['rowid'])) + if (empty($ulprinted) && !empty($pere['rowid'])) { - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) { dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; continue; } - print ''; $ulprinted++; + print ''; $ulprinted++; } - print "\n".'
  • '; + print "\n".'
  • '; if ($showfk) { print ''; print ''; - print ''; print ''; - print ''; print ''; @@ -685,7 +685,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1))); + $default = (empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1))); print ''; print ''; @@ -698,7 +698,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) { print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default")); } - print '   ('.$langs->trans("Default").': '.$default.') '; // $colorbacktitle1 in CSS + print '   ('.$langs->trans("Default").': '.$default.') '; // $colorbacktitle1 in CSS print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; @@ -712,7 +712,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle))); + $default = (empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle))); print ''; print ''; @@ -739,11 +739,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1))); + $default = (empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1))); print ''; print ''; - print ''; print ''; - print ''; print ''; @@ -857,22 +857,22 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) */ } else { - $default=(empty($colorbacklinepairhover) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairhover))); + $default = (empty($colorbacklinepairhover) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairhover))); print ''; print ''; - print ''; print ''; diff --git a/htdocs/core/lib/vat.lib.php b/htdocs/core/lib/vat.lib.php index 1649e686ec2..0bc3bb66e90 100644 --- a/htdocs/core/lib/vat.lib.php +++ b/htdocs/core/lib/vat.lib.php @@ -49,12 +49,12 @@ function vat_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->tax->dir_output . "/vat/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->tax->dir_output."/vat/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; $head[$tab][2] = 'documents'; $tab++; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 0822109d45e..af8840b33ae 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -562,7 +562,7 @@ function getStructuredData($type, $data = array()) } elseif ($type == 'blogpost') { - if (! empty($websitepage->author_alias)) + if (!empty($websitepage->author_alias)) { //include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; //$tmpuser = new User($db); @@ -665,24 +665,24 @@ function getSocialNetworkSharingLinks() $hashtags = trim(join(' #', array_map('trim', explode(',', $websitepage->keywords)))); $out = ''."\n"; - $out.= ' -global->MAIN_VIEW_LINE_NUMBER)) { ?> - +global->MAIN_VIEW_LINE_NUMBER)) { ?> + info_bits & 2) != 2) { - print 'fk_prev_id != null ) print ' readonly'; + print 'fk_prev_id != null) print ' readonly'; print '>%'; } else { ?>   @@ -216,7 +216,7 @@ $coldisplay++; ?> - global->MAIN_VIEW_LINE_NUMBER)) { ?> + global->MAIN_VIEW_LINE_NUMBER)) { ?> - "; print "\n"; - if ( $object->socid && ! empty($conf->societe->enabled) && ! empty($conf->global->DONATION_USE_THIRDPARTIES) ) { - $company=new Societe($db); - $result=$company->fetch($object->socid); + if ($object->socid && !empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { + $company = new Societe($db); + $result = $company->fetch($object->socid); print ''; } else { @@ -547,14 +547,14 @@ if (!empty($id) && $action == 'edit') // Zip / Town print ''; // Country print ''; if ($object->socid) { - $company=new Societe($db); - $result=$company->fetch($object->socid); + $company = new Societe($db); + $result = $company->fetch($object->socid); print ''; } else { @@ -865,7 +865,7 @@ if (!empty($id) && $action != 'edit') $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online payment link - $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT && { diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 95ea92f1ff3..872e2009b9b 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -63,16 +63,16 @@ class Donations extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->don->lire) { + if (!DolibarrApiAccess::$user->rights->don->lire) { throw new RestException(401); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -109,33 +109,33 @@ class Donations extends DolibarrApi $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."don as t"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."don as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('don').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." "; + $sql .= ' WHERE t.entity IN ('.getEntity('don').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($thirdparty_ids) $sql .= " AND t.fk_soc = ".$thirdparty_ids." "; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -145,12 +145,12 @@ class Donations extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $don_static = new Don($db); - if($don_static->fetch($obj->rowid)) { + if ($don_static->fetch($obj->rowid)) { // Add external contacts ids //$don_static->contacts_ids = $don_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($don_static); @@ -161,7 +161,7 @@ class Donations extends DolibarrApi else { throw new RestException(503, 'Error when retrieve donation list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No donation found'); } @@ -176,7 +176,7 @@ class Donations extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -210,16 +210,16 @@ class Donations extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); } $result = $this->don->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -245,19 +245,19 @@ class Donations extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->don->supprimer) { + if (!DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->don->delete(DolibarrApiAccess::$user)) { + if (!$this->don->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete donation : '.$this->don->error); } @@ -293,15 +293,15 @@ class Donations extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -313,11 +313,11 @@ class Donations extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->don->error); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -360,7 +360,7 @@ class Donations extends DolibarrApi $don = array(); foreach (Orders::$FIELDS as $field) { if (!isset($data[$field])) - throw new RestException(400, $field ." field missing"); + throw new RestException(400, $field." field missing"); $don[$field] = $data[$field]; } return $don; diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 607d6555337..5370bdcaf73 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -24,9 +24,9 @@ * \brief File of class to manage donations statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -76,15 +76,15 @@ class DonationStats extends Stats $this->userid = $userid; $this->cachefilesuffix = $mode; - $object=new Don($this->db); + $object = new Don($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as d"; //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; //$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE - $this->where.= " d.fk_statut > 0"; // Not draft and not cancelled + $this->where .= " d.fk_statut > 0"; // Not draft and not cancelled //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= " AND d.entity = ".$conf->entity; - if ($this->userid > 0) $this->where.=' WHERE c.fk_user_author = '.$this->userid; + $this->where .= " AND d.entity = ".$conf->entity; + if ($this->userid > 0) $this->where .= ' WHERE c.fk_user_author = '.$this->userid; } /** @@ -99,13 +99,13 @@ class DonationStats extends Stats global $user; $sql = "SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -120,10 +120,10 @@ class DonationStats extends Stats global $user; $sql = "SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -138,10 +138,10 @@ class DonationStats extends Stats global $user; $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 22b75cd777b..ee8156c229e 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -32,12 +32,12 @@ class PaymentDonation extends CommonObject /** * @var string ID to identify managed object */ - public $element='payment_donation'; + public $element = 'payment_donation'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='payment_donation'; + public $table_element = 'payment_donation'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -54,11 +54,11 @@ class PaymentDonation extends CommonObject */ public $fk_donation; - public $datec=''; - public $tms=''; - public $datep=''; - public $amount; // Total amount of payment - public $amounts=array(); // Array of amounts + public $datec = ''; + public $tms = ''; + public $datep = ''; + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts public $typepayment; public $num_payment; @@ -109,23 +109,23 @@ class PaymentDonation extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Validate parameters - if (! $this->datepaid) + if (!$this->datepaid) { - $this->error='ErrorBadValueForParameterCreatePaymentDonation'; + $this->error = 'ErrorBadValueForParameterCreatePaymentDonation'; return -1; } // Clean parameters if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); - if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -148,15 +148,15 @@ class PaymentDonation extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,"; - $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->datepaid)."',"; - $sql.= " ".$totalamount.","; - $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".$user->id.","; - $sql.= " 0)"; + $sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; + $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datepaid)."',"; + $sql .= " ".$totalamount.","; + $sql .= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".$user->id.","; + $sql .= " 0)"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation"); @@ -168,24 +168,24 @@ class PaymentDonation extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('DONATION_PAYMENT_CREATE', $user); + $result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if ($totalamount != 0 && ! $error) + if ($totalamount != 0 && !$error) { - $this->amount=$totalamount; - $this->total=$totalamount; // deprecated + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated $this->db->commit(); return $this->id; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -201,27 +201,27 @@ class PaymentDonation extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.fk_donation,"; - $sql.= " t.datec,"; - $sql.= " t.tms,"; - $sql.= " t.datep,"; - $sql.= " t.amount,"; - $sql.= " t.fk_typepayment,"; - $sql.= " t.num_payment,"; - $sql.= " t.note as note_public,"; - $sql.= " t.fk_bank,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_label,"; - $sql.= ' b.fk_account'; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.fk_donation,"; + $sql .= " t.datec,"; + $sql .= " t.tms,"; + $sql .= " t.datep,"; + $sql .= " t.amount,"; + $sql .= " t.fk_typepayment,"; + $sql .= " t.num_payment,"; + $sql .= " t.note as note_public,"; + $sql .= " t.fk_bank,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_modif,"; + $sql .= " pt.code as type_code, pt.libelle as type_label,"; + $sql .= ' b.fk_account'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -231,23 +231,23 @@ class PaymentDonation extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->fk_donation = $obj->fk_donation; + $this->fk_donation = $obj->fk_donation; $this->datec = $this->db->jdate($obj->datec); - $this->tms = $this->db->jdate($obj->tms); + $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); - $this->amount = $obj->amount; - $this->fk_typepayment = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->note_public = $obj->note_public; - $this->fk_bank = $obj->fk_bank; + $this->amount = $obj->amount; + $this->fk_typepayment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->note_public = $obj->note_public; + $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; - $this->type_code = $obj->type_code; - $this->type_label = $obj->type_label; + $this->type_code = $obj->type_code; + $this->type_label = $obj->type_label; - $this->bank_account = $obj->fk_account; - $this->bank_line = $obj->fk_bank; + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; } $this->db->free($resql); @@ -255,7 +255,7 @@ class PaymentDonation extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -271,15 +271,15 @@ class PaymentDonation extends CommonObject public function update($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); - if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -289,36 +289,36 @@ class PaymentDonation extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET"; - $sql.= " fk_donation=".(isset($this->fk_donation)?$this->fk_donation:"null").","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; - $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; - $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; - $sql.= " note=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; - $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; - $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; - $sql.= " WHERE rowid=".(int) $this->id; + $sql .= " fk_donation=".(isset($this->fk_donation) ? $this->fk_donation : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").","; + $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; + $sql .= " note=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + $sql .= " WHERE rowid=".(int) $this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[]="Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('DONATION_PAYMENT_MODIFY', $user); + $result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -328,13 +328,13 @@ class PaymentDonation extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -354,41 +354,41 @@ class PaymentDonation extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_donation' AND url_id=".(int) $this->id; + $sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[]="Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('DONATION_PAYMENT_DELETE', $user); + $result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -398,13 +398,13 @@ class PaymentDonation extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -424,39 +424,39 @@ class PaymentDonation extends CommonObject */ public function createFromClone(User $user, $fromid) { - $error=0; + $error = 0; - $object=new PaymentDonation($this->db); + $object = new PaymentDonation($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); - $object->id=0; - $object->statut=0; + $object->id = 0; + $object->statut = 0; // Clear fields // ... // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); // Other options if ($result < 0) { - $this->error=$object->error; + $this->error = $object->error; $error++; } - if (! $error) + if (!$error) { } unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -506,19 +506,19 @@ class PaymentDonation extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->fk_donation=''; - $this->datec=''; - $this->tms=''; - $this->datep=''; - $this->amount=''; - $this->fk_typepayment=''; - $this->num_payment=''; - $this->note_public=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; + $this->fk_donation = ''; + $this->datec = ''; + $this->tms = ''; + $this->datep = ''; + $this->amount = ''; + $this->fk_typepayment = ''; + $this->num_payment = ''; + $this->note_public = ''; + $this->fk_bank = ''; + $this->fk_user_creat = ''; + $this->fk_user_modif = ''; } @@ -538,22 +538,22 @@ class PaymentDonation extends CommonObject { global $conf; - $error=0; + $error = 0; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); - $total=$this->total; - if ($mode == 'payment_donation') $amount=$total; + $total = $this->total; + if ($mode == 'payment_donation') $amount = $total; // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaid, - $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") + $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $label, $amount, $this->num_payment, @@ -567,7 +567,7 @@ class PaymentDonation extends CommonObject // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { - $result=$this->update_fk_bank($bank_line_id); + $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; @@ -575,11 +575,11 @@ class PaymentDonation extends CommonObject } // Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction - $url=''; - if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/don/payment/card.php?rowid='; + $url = ''; + if ($mode == 'payment_donation') $url = DOL_URL_ROOT.'/don/payment/card.php?rowid='; if ($url) { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; @@ -589,12 +589,12 @@ class PaymentDonation extends CommonObject } else { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } - if (! $error) + if (!$error) { return 1; } @@ -625,7 +625,7 @@ class PaymentDonation extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return 0; } } @@ -641,18 +641,18 @@ class PaymentDonation extends CommonObject { global $langs; - $result=''; + $result = ''; $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) { $link = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; } return $result; diff --git a/htdocs/don/document.php b/htdocs/don/document.php index dba5b4cff7b..8dbb6f99fda 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -50,7 +50,7 @@ $confirm = GETPOST('confirm', 'alpha'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'don', $id, ''); @@ -101,27 +101,27 @@ if ($object->id) { $object->fetch_thirdparty(); - $head=donation_prepare_head($object); + $head = donation_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'generic'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { @@ -129,28 +129,28 @@ if ($object->id) } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/don/info.php b/htdocs/don/info.php index e2249e082a7..cff4aceae79 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -34,12 +34,12 @@ if (!empty($conf->projet->enabled)) $langs->load("donations"); $id = GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'don', $id, ''); $object = new Don($db); @@ -69,14 +69,14 @@ $head = donation_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("Donation"), -1, 'generic'); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
    '; +$morehtmlref = '
    '; // Project -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { @@ -84,28 +84,28 @@ if (! empty($conf->projet->enabled)) } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } -$morehtmlref.='
    '; +$morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/don/note.php b/htdocs/don/note.php index 128ea2163c7..08b8c05b520 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -29,35 +29,35 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("companies","bills","donations")); +$langs->loadLangs(array("companies", "bills", "donations")); -$id=(GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('facid', 'int')); // For backward compatibility -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check -$socid=0; -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'don', $id, ''); +$socid = 0; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'don', $id, ''); $object = new Don($db); $object->fetch($id); -$permissionnote=$user->rights->don->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->don->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once if ($action == 'classin' && $user->rights->don->creer) { @@ -85,14 +85,14 @@ if ($id > 0 || !empty($ref)) dol_fiche_head($head, 'note', $langs->trans("Donation"), -1, 'generic'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { @@ -100,35 +100,35 @@ if ($id > 0 || !empty($ref)) } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); print '
    '; print '
    '; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index c5517a72696..0017f0a8556 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -27,24 +27,24 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; -if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","banks","companies")); +$langs->loadLangs(array("bills", "banks", "companies")); // Security check -$id=GETPOST('rowid')?GETPOST('rowid', 'int'):GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +if ($user->socid) $socid = $user->socid; // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentDonation($db); if ($id > 0) { - $result=$object->fetch($id); - if (! $result) dol_print_error($db, 'Failed to get payment id '.$id); + $result = $object->fetch($id); + if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); } @@ -76,20 +76,20 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->cree { $db->begin(); - $result=$object->valide(); + $result = $object->valide(); if ($result > 0) { $db->commit(); - $factures=array(); // TODO Get all id of invoices linked to this payment - foreach($factures as $id) + $factures = array(); // TODO Get all id of invoices linked to this payment + foreach ($factures as $id) { $fac = new Facture($db); $fac->fetch($id); $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) + if (!empty($_REQUEST['lang_id'])) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); @@ -119,7 +119,7 @@ llxHeader(); $don = new Don($db); $form = new Form($db); -$h=0; +$h = 0; $head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id; $head[$h][1] = $langs->trans("Card"); @@ -176,11 +176,11 @@ print '
    '; // Bank account -if (! empty($conf->banque->enabled)) +if (!empty($conf->banque->enabled)) { if ($object->bank_account) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); print ''; @@ -201,13 +201,13 @@ print '
    '; @@ -216,14 +216,14 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset print $tab[$x]['entry']; } //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
    '."\n"; - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); // And now we search all its sons of lower level //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."
    \n"; - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); print ''; } } - if (! empty($ulprinted) && ! empty($pere['rowid'])) { print ''."\n"; } + if (!empty($ulprinted) && !empty($pere['rowid'])) { print ''."\n"; } if ($rang == 0) print ''; } diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index cb54b263a00..ec8c6a6858f 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -34,7 +34,7 @@ function trip_prepare_head(Deplacement $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -50,7 +50,7 @@ function trip_prepare_head(Deplacement $object) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2b510373299..bc20612c747 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -582,11 +582,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbackhmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackhmenu1))); + $default = (empty($colorbackhmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackhmenu1))); print '
    '.$langs->trans("TopMenuBackgroundColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''), 'THEME_ELDY_TOPMENU_BACK1', 'formcolor', 1).' '; @@ -630,11 +630,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbackvmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackvmenu1))); + $default = (empty($colorbackvmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackvmenu1))); print '
    '.$langs->trans("LeftMenuBackgroundColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''), 'THEME_ELDY_VERMENU_BACK1', 'formcolor', 1).' '; @@ -658,7 +658,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab))); + $default = (empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab))); print '
    '.$langs->trans("TextTitleColor").'
    '.$langs->trans("BackgroundTableTitleColor").'
    '.$langs->trans("BackgroundTableTitleTextColor").'
    '.$langs->trans("BackgroundTableLineOddColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''), 'THEME_ELDY_LINEIMPAIR1', 'formcolor', 1).' '; @@ -767,11 +767,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1))); + $default = (empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1))); print '
    '.$langs->trans("BackgroundTableLineEvenColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''), 'THEME_ELDY_LINEPAIR1', 'formcolor', 1).' '; @@ -815,7 +815,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colortextlink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortextlink))); + $default = (empty($colortextlink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortextlink))); print '
    '.$langs->trans("LinkColor").'
    '.$langs->trans("HighlightLinesColor").''; + print ''; //print ''; //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; if ($edit) { - if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover)); + if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', 'formcolor', 1).' '; } else { - if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover)); + if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); if ($color) { @@ -903,7 +903,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked))); + $default = (empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked))); print '
    '.$langs->trans("HighlightLinesChecked").'
    - product->enabled) || ! empty($conf->service->enabled)) { ?> + product->enabled) || !empty($conf->service->enabled)) { ?> @@ -264,17 +264,17 @@ if (!empty($extrafields)) } ?> -service->enabled) && $line->product_type == 1 && $dateSelector) { ?> +service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
    trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); - print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start?0:1, "updateline", 1, 0); + $hourmin = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : ''); + print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start ? 0 : 1, "updateline", 1, 0); print ' '.$langs->trans('to').' '; - print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end?0:1, "updateline", 1, 0); + print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end ? 0 : 1, "updateline", 1, 0); print '"; -print ''; -print ''; +print ''; +print ''; print ''; print ''; if ($conf->global->MAIN_MULTILANGS) { - print ''; } -$subject = 'DATAPOLICIESSUBJECT_' . $l; -$linka = 'TXTLINKDATAPOLICIESACCEPT_' . $l; -$linkr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; -$content = 'DATAPOLICIESCONTENT_' . $l; -$acc = 'DATAPOLICIESACCEPT_' . $l; -$ref = 'DATAPOLICIESREFUSE_' . $l; +$subject = 'DATAPOLICIESSUBJECT_'.$l; +$linka = 'TXTLINKDATAPOLICIESACCEPT_'.$l; +$linkr = 'TXTLINKDATAPOLICIESREFUSE_'.$l; +$content = 'DATAPOLICIESCONTENT_'.$l; +$acc = 'DATAPOLICIESACCEPT_'.$l; +$ref = 'DATAPOLICIESREFUSE_'.$l; print ''; print ''; print ''; print ''; print ''; print '
    ' . $form->editfieldkey('DefaultLang', 'default_lang', '', null, 0) . '' . "\n"; + print '
    '.$form->editfieldkey('DefaultLang', 'default_lang', '', null, 0).''."\n"; print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print '
    '; -print $langs->trans('DATAPOLICIESSUBJECTMAIL') . ''; -print ''; +print $langs->trans('DATAPOLICIESSUBJECTMAIL').''; +print ''; print '
    '; print $langs->trans('DATAPOLICIESCONTENTMAIL').''; -print $langs->trans('DATAPOLICIESSUBSITUTION');echo'__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__'; +print $langs->trans('DATAPOLICIESSUBSITUTION'); echo'__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__'; $doleditor = new DolEditor($content, $conf->global->$content, '', 250, 'Full', '', false, true, 1, 200, 70); $doleditor->Create(); print '
    '; -print $langs->trans('TXTLINKDATAPOLICIESACCEPT') . ''; -print ''; +print $langs->trans('TXTLINKDATAPOLICIESACCEPT').''; +print ''; print '
    '; -print $langs->trans('TXTLINKDATAPOLICIESREFUSE') . ''; -print ''; +print $langs->trans('TXTLINKDATAPOLICIESREFUSE').''; +print ''; print '
    '; @@ -149,7 +149,7 @@ $doleditor->Create(); print '
    '; -print '
    '; +print '
    '; print ''; diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 7d467729841..3ef5a12d720 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -133,22 +133,22 @@ class ActionsDatapolicy header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); header('Pragma: no-cache'); $object->fetch(GETPOST('socid')); - echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;' . PHP_EOL; - echo $object->name . ';'; + echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; + echo $object->name.';'; echo ';'; echo ';'; echo ';'; echo ';'; - echo $object->address . ';'; - echo $object->zip . ';'; - echo $object->town . ';'; - echo $object->state . ';'; - echo $object->country . ';'; - echo $object->email . ';'; - echo $object->phone . ';'; + echo $object->address.';'; + echo $object->zip.';'; + echo $object->town.';'; + echo $object->state.';'; + echo $object->country.';'; + echo $object->email.';'; + echo $object->phone.';'; echo ';'; echo ';'; - echo $object->skype . ';'; + echo $object->skype.';'; echo ';'; exit; } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'datapolicy_portabilite') { @@ -157,23 +157,23 @@ class ActionsDatapolicy header('Pragma: no-cache'); $soc = $object->fetch_thirdparty(); - echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;' . PHP_EOL; - echo $object->lastname . ';'; - echo $object->firstname . ';'; - echo $object->getCivilityLabel() . ';'; - echo ($soc != -1 ? $object->thirdparty->name : '') . ';'; + echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; + echo $object->lastname.';'; + echo $object->firstname.';'; + echo $object->getCivilityLabel().';'; + echo ($soc != -1 ? $object->thirdparty->name : '').';'; echo ';'; - echo $object->address . ';'; - echo $object->zip . ';'; - echo $object->town . ';'; - echo $object->state . ';'; - echo $object->country . ';'; - echo $object->email . ';'; - echo $object->phone . ';'; - echo $object->phone_perso . ';'; - echo $object->phone_mobile . ';'; - echo $object->skype . ';'; - echo dol_print_date($object->birth) . ';'; + echo $object->address.';'; + echo $object->zip.';'; + echo $object->town.';'; + echo $object->state.';'; + echo $object->country.';'; + echo $object->email.';'; + echo $object->phone.';'; + echo $object->phone_perso.';'; + echo $object->phone_mobile.';'; + echo $object->skype.';'; + echo dol_print_date($object->birth).';'; exit; } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'datapolicy_portabilite') { $object->fetch(GETPOST('id')); @@ -181,39 +181,39 @@ class ActionsDatapolicy header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); header('Pragma: no-cache'); $soc = $object->fetch_thirdparty(); - echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;' . PHP_EOL; - echo $object->lastname . ';'; - echo $object->firstname . ';'; - echo $object->getCivilityLabel() . ';'; - echo ($soc != -1 ? $object->thirdparty->name : '') . ';'; - echo $object->poste . ';'; - echo $object->address . ';'; - echo $object->zip . ';'; - echo $object->town . ';'; - echo $object->state . ';'; - echo $object->country . ';'; - echo $object->email . ';'; - echo $object->phone_pro . ';'; - echo $object->phone_perso . ';'; - echo $object->phone_mobile . ';'; - echo $object->jabberid . ';'; - echo dol_print_date($object->birth) . ';'; + echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; + echo $object->lastname.';'; + echo $object->firstname.';'; + echo $object->getCivilityLabel().';'; + echo ($soc != -1 ? $object->thirdparty->name : '').';'; + echo $object->poste.';'; + echo $object->address.';'; + echo $object->zip.';'; + echo $object->town.';'; + echo $object->state.';'; + echo $object->country.';'; + echo $object->email.';'; + echo $object->phone_pro.';'; + echo $object->phone_perso.';'; + echo $object->phone_mobile.';'; + echo $object->jabberid.';'; + echo dol_print_date($object->birth).';'; exit; } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('id')); - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; DataPolicy::sendMailDataPolicyContact($object); } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('id')); - require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; DataPolicy::sendMailDataPolicyAdherent($object); } elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('socid')); - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; DataPolicy::sendMailDataPolicyCompany($object); } @@ -278,7 +278,7 @@ class ActionsDatapolicy /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' - $this->resprints = ''; + $this->resprints = ''; } if (!$error) { @@ -308,7 +308,7 @@ class ActionsDatapolicy $ret = 0; $deltemp = array(); - dol_syslog(get_class($this) . '::executeHooks action=' . $action); + dol_syslog(get_class($this).'::executeHooks action='.$action); /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' @@ -332,10 +332,10 @@ class ActionsDatapolicy global $conf, $user, $langs; $langs->load('datapolicy@datapolicy'); - if (! empty($conf->global->DATAPOLICIES_ENABLE_EMAILS)) + if (!empty($conf->global->DATAPOLICIES_ENABLE_EMAILS)) { - $dialog = '
    '.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).'
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
    '.$langs->trans('Country').''; - print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code), 'country_id'); + print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id'); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -634,43 +634,43 @@ if (!empty($id) && $action != 'edit') // Print form confirm print $formconfirm; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref.=''; - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= ''; + $morehtmlref .= '
    '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -696,8 +696,8 @@ if (!empty($id) && $action != 'edit') print '
    '.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).'
    '.$langs->trans('Amount').''.price($object->amount, 0, $ print '
    '.$langs->trans('Note').''.nl2br($object->note_public).'
    '; $disable_delete = 0; $sql = 'SELECT d.rowid as did, d.paid, d.amount as d_amount, pd.amount'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_donation as pd,'.MAIN_DB_PREFIX.'don as d'; -$sql.= ' WHERE pd.fk_donation = d.rowid'; -$sql.= ' AND d.entity = '.$conf->entity; -$sql.= ' AND pd.rowid = '.$id; +$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_donation as pd,'.MAIN_DB_PREFIX.'don as d'; +$sql .= ' WHERE pd.fk_donation = d.rowid'; +$sql .= ' AND d.entity = '.$conf->entity; +$sql .= ' AND pd.rowid = '.$id; dol_syslog("don/payment/card.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -286,7 +286,7 @@ if (empty($action)) { if ($user->rights->don->supprimer) { - if (! $disable_delete) + if (!$disable_delete) { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 182f7697601..46b0d93d564 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -29,11 +29,11 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/donstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$userid=GETPOST('userid', 'int'); -$socid=GETPOST('socid', 'int'); +$userid = GETPOST('userid', 'int'); +$socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { @@ -41,21 +41,21 @@ if ($user->socid > 0) $socid = $user->socid; } -$nowyear=strftime("%Y", dol_now()); -$year = GETPOST('year')>0?GETPOST('year'):$nowyear; +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; //$startyear=$year-2; -$startyear=$year-1; -$endyear=$year; +$startyear = $year - 1; +$endyear = $year; // Load translation files required by the page -$langs->loadLangs(array("companies","other","sendings")); +$langs->loadLangs(array("companies", "other", "sendings")); /* * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); @@ -64,7 +64,7 @@ print load_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg); dol_mkdir($dir); -$stats = new DonationStats($db, $socid, '', ($userid>0?$userid:0)); +$stats = new DonationStats($db, $socid, '', ($userid > 0 ? $userid : 0)); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); @@ -83,13 +83,13 @@ else $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px1->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px1->SetLegend($legend); @@ -100,7 +100,7 @@ if (! $mesg) $px1->SetYLabel($langs->trans("NbOfSendings")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -188,22 +188,22 @@ if (! $mesg) // Show array $data = $stats->getAllByYear(); -$arrayyears=array(); -foreach($data as $val) { - if (! empty($val['year'])) { - $arrayyears[$val['year']]=$val['year']; +$arrayyears = array(); +foreach ($data as $val) { + if (!empty($val['year'])) { + $arrayyears[$val['year']] = $val['year']; } } -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; -$h=0; +$h = 0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/don/stats/index.php'; +$head[$h][0] = DOL_URL_ROOT.'/don/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -$type='donation_stats'; +$type = 'donation_stats'; complete_head_from_modules($conf, $langs, null, $head, $h, $type); @@ -231,8 +231,8 @@ print '
    '; print '
  • '.$langs->trans("Year").''; - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print '
    '.$langs->trans("NbOfSendings").''.$langs->trans("AmountAverage").'
    '.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
    '; diff --git a/htdocs/don/tpl/linkedobjectblock.tpl.php b/htdocs/don/tpl/linkedobjectblock.tpl.php index 94a676f964d..18c410ba4d0 100644 --- a/htdocs/don/tpl/linkedobjectblock.tpl.php +++ b/htdocs/don/tpl/linkedobjectblock.tpl.php @@ -29,13 +29,13 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("donations"); -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) { +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; print ''; print ''.$langs->trans("Donation").''; print ''.$objectlink->getNomUrl(1).''; @@ -52,7 +52,7 @@ print ''; if (count($linkedObjectBlock) > 1) { ?> - + trans("Total"); ?> diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index 754f68a9930..9f4820cd723 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -20,15 +20,15 @@ * \brief File to build ecm database */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $element = GETPOST('element', 'alpha'); /* @@ -40,13 +40,13 @@ top_httphead(); //print ''."\n"; // Load original field value -if (isset($action) && ! empty($action)) +if (isset($action) && !empty($action)) { - $error=0; + $error = 0; - if ($action == 'build' && ! empty($element)) + if ($action == 'build' && !empty($element)) { - require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php'; + require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; $ecmdirstatic = new EcmDirectory($db); $ecmdirtmp = new EcmDirectory($db); @@ -54,57 +54,57 @@ if (isset($action) && ! empty($action)) // This part of code is same than into file index.php for action refreshmanual TODO Remove duplicate clearstatcache(); - $diroutputslash=str_replace('\\', '/', $conf->$element->dir_output); - $diroutputslash.='/'; + $diroutputslash = str_replace('\\', '/', $conf->$element->dir_output); + $diroutputslash .= '/'; // Scan directory tree on disk - $disktree=dol_dir_list($conf->$element->dir_output, 'directories', 1, '', array('^temp$'), '', '', 0); + $disktree = dol_dir_list($conf->$element->dir_output, 'directories', 1, '', array('^temp$'), '', '', 0); // Scan directory tree in database - $sqltree=$ecmdirstatic->get_full_arbo(0); + $sqltree = $ecmdirstatic->get_full_arbo(0); - $adirwascreated=0; + $adirwascreated = 0; // Now we compare both trees to complete missing trees into database //var_dump($disktree); //var_dump($sqltree); - foreach($disktree as $dirdesc) // Loop on tree onto disk + foreach ($disktree as $dirdesc) // Loop on tree onto disk { set_time_limit(0); // To force restarts the timeout counter from zero - $dirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($conf->$element->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) { - $dirisindatabase=1; + $dirisindatabase = 1; break; } } - if (! $dirisindatabase) + if (!$dirisindatabase) { - $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent=-1; - $relativepathmissing=str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent=$relativepathmissing; + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); if (preg_match('/\//', $relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent)) { - $relativepathtosearchparent=preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; dol_syslog($txt); //print $txt." -> "; - $parentdirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) { - $parentdirisindatabase=$dirsqldesc['id']; + $parentdirisindatabase = $dirsqldesc['id']; break; } } @@ -112,7 +112,7 @@ if (isset($action) && ! empty($action)) { dol_syslog("Yes with id ".$parentdirisindatabase); //print "Yes with id ".$parentdirisindatabase."
    \n"; - $fk_parent=$parentdirisindatabase; + $fk_parent = $parentdirisindatabase; //break; // We found parent, we can stop the while loop } else @@ -124,7 +124,7 @@ if (isset($action) && ! empty($action)) else { dol_syslog("Parent is root"); - $fk_parent=0; // Parent is root + $fk_parent = 0; // Parent is root } if ($fk_parent >= 0) @@ -134,20 +134,20 @@ if (isset($action) && ! empty($action)) $ecmdirtmp->description = ''; $ecmdirtmp->fk_parent = $fk_parent; - $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $txt."
    \n"; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql=array('id'=>$id, + $newdirsql = array('id'=>$id, 'id_mere'=>$ecmdirtmp->fk_parent, 'label'=>$ecmdirtmp->label, 'description'=>$ecmdirtmp->description, 'fullrelativename'=>$relativepathmissing); - $sqltree[]=$newdirsql; // We complete fulltree for following loops + $sqltree[] = $newdirsql; // We complete fulltree for following loops //var_dump($sqltree); - $adirwascreated=1; + $adirwascreated = 1; } else { @@ -155,7 +155,7 @@ if (isset($action) && ! empty($action)) } } else { - $txt="Parent of ".$dirdesc['fullname']." not found"; + $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); //print $txt."
    \n"; } @@ -163,19 +163,19 @@ if (isset($action) && ! empty($action)) } // Loop now on each sql tree to check if dir exists - foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk { - $dirtotest=$conf->$element->dir_output.'/'.$dirdesc['fullrelativename']; - if (! dol_is_dir($dirtotest)) + $dirtotest = $conf->$element->dir_output.'/'.$dirdesc['fullrelativename']; + if (!dol_is_dir($dirtotest)) { - $mesg.=$dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."
    \n"; - $ecmdirtmp->id=$dirdesc['id']; + $mesg .= $dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."
    \n"; + $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } } - $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); } diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index c8c67f82b9c..3bddd70bfaa 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -30,7 +30,7 @@ class EcmDirectory // extends CommonObject /** * @var string ID to identify managed object */ - public $element='ecm_directories'; + public $element = 'ecm_directories'; /** * @var string Name of table without prefix where object is stored @@ -62,7 +62,7 @@ class EcmDirectory // extends CommonObject */ public $description; - public $cachenbofdoc=-1; // By default cache initialized with value 'not calculated' + public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated' public $date_c; public $date_m; @@ -81,11 +81,11 @@ class EcmDirectory // extends CommonObject */ public $ref; - public $cats=array(); - public $motherof=array(); + public $cats = array(); + public $motherof = array(); - public $forbiddenchars = array('<','>',':','/','\\','?','*','|','"'); - public $forbiddencharsdir = array('<','>',':','?','*','|','"'); + public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"'); + public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"'); public $full_arbo_loaded; @@ -122,46 +122,46 @@ class EcmDirectory // extends CommonObject { global $conf, $langs; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->label=dol_sanitizeFileName(trim($this->label)); - $this->fk_parent=trim($this->fk_parent); - $this->description=trim($this->description); - $this->date_c=$now; - $this->fk_user_c=$user->id; - if ($this->fk_parent <= 0) $this->fk_parent=0; + $this->label = dol_sanitizeFileName(trim($this->label)); + $this->fk_parent = trim($this->fk_parent); + $this->description = trim($this->description); + $this->date_c = $now; + $this->fk_user_c = $user->id; + if ($this->fk_parent <= 0) $this->fk_parent = 0; // Check if same directory does not exists with this name - $relativepath=$this->label; + $relativepath = $this->label; if ($this->fk_parent) { $parent = new EcmDirectory($this->db); $parent->fetch($this->fk_parent); - $relativepath=$parent->getRelativePath().$relativepath; + $relativepath = $parent->getRelativePath().$relativepath; } - $relativepath=preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \ + $relativepath = preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \ //print $relativepath.'
    '; $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(1); - $pathfound=0; + $pathfound = 0; foreach ($cate_arbo as $key => $categ) { - $path=str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']); + $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']); //print $relativepath.' - '.$path.'
    '; if ($path == $relativepath) { - $pathfound=1; + $pathfound = 1; break; } } if ($pathfound) { - $this->error="ErrorDirAlreadyExists"; + $this->error = "ErrorDirAlreadyExists"; dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); return -1; } @@ -171,39 +171,39 @@ class EcmDirectory // extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories("; - $sql.= "label,"; - $sql.= "entity,"; - $sql.= "fk_parent,"; - $sql.= "description,"; - $sql.= "cachenbofdoc,"; - $sql.= "date_c,"; - $sql.= "fk_user_c"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->escape($this->label)."',"; - $sql.= " '".$this->db->escape($conf->entity)."',"; - $sql.= " '".$this->db->escape($this->fk_parent)."',"; - $sql.= " '".$this->db->escape($this->description)."',"; - $sql.= " ".$this->cachenbofdoc.","; - $sql.= " '".$this->db->idate($this->date_c)."',"; - $sql.= " '".$this->db->escape($this->fk_user_c)."'"; - $sql.= ")"; + $sql .= "label,"; + $sql .= "entity,"; + $sql .= "fk_parent,"; + $sql .= "description,"; + $sql .= "cachenbofdoc,"; + $sql .= "date_c,"; + $sql .= "fk_user_c"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->escape($this->label)."',"; + $sql .= " '".$this->db->escape($conf->entity)."',"; + $sql .= " '".$this->db->escape($this->fk_parent)."',"; + $sql .= " '".$this->db->escape($this->description)."',"; + $sql .= " ".$this->cachenbofdoc.","; + $sql .= " '".$this->db->idate($this->date_c)."',"; + $sql .= " '".$this->db->escape($this->fk_user_c)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories"); - $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath(); - $result=dol_mkdir($dir); - if ($result < 0) { $error++; $this->error="ErrorFailedToCreateDir"; } + $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath(); + $result = dol_mkdir($dir); + if ($result < 0) { $error++; $this->error = "ErrorFailedToCreateDir"; } // Call trigger - $result=$this->call_trigger('MYECMDIR_CREATE', $user); + $result = $this->call_trigger('MYECMDIR_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -216,7 +216,7 @@ class EcmDirectory // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } @@ -234,12 +234,12 @@ class EcmDirectory // extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - $this->label=trim($this->label); - $this->fk_parent=trim($this->fk_parent); - $this->description=trim($this->description); + $this->label = trim($this->label); + $this->fk_parent = trim($this->fk_parent); + $this->description = trim($this->description); // Check parameters // Put here code to add control on parameters values @@ -248,28 +248,28 @@ class EcmDirectory // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " fk_parent='".$this->db->escape($this->fk_parent)."',"; - $sql.= " description='".$this->db->escape($this->description)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " fk_parent='".$this->db->escape($this->fk_parent)."',"; + $sql .= " description='".$this->db->escape($this->description)."'"; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MYECMDIR_MODIFY', $user); + $result = $this->call_trigger('MYECMDIR_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -292,15 +292,15 @@ class EcmDirectory // extends CommonObject { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - if (preg_match('/[0-9]+/', $value)) $sql.= " cachenbofdoc = ".(int) $value; - else $sql.= " cachenbofdoc = cachenbofdoc ".$value." 1"; - $sql.= " WHERE rowid = ".$this->id; + if (preg_match('/[0-9]+/', $value)) $sql .= " cachenbofdoc = ".(int) $value; + else $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } else @@ -323,20 +323,20 @@ class EcmDirectory // extends CommonObject public function fetch($id) { $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.label,"; - $sql.= " t.fk_parent,"; - $sql.= " t.description,"; - $sql.= " t.cachenbofdoc,"; - $sql.= " t.fk_user_c,"; - $sql.= " t.fk_user_m,"; - $sql.= " t.date_c as date_c,"; - $sql.= " t.date_m as date_m"; - $sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.label,"; + $sql .= " t.fk_parent,"; + $sql .= " t.description,"; + $sql .= " t.cachenbofdoc,"; + $sql .= " t.fk_user_c,"; + $sql .= " t.fk_user_m,"; + $sql .= " t.date_c as date_c,"; + $sql .= " t.date_m as date_m"; + $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -357,11 +357,11 @@ class EcmDirectory // extends CommonObject $this->db->free($resql); - return $obj?1:0; + return $obj ? 1 : 0; } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -380,29 +380,29 @@ class EcmDirectory // extends CommonObject global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; - if ($mode != 'databaseonly') $relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3 + if ($mode != 'databaseonly') $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3 - dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly')?'':' relativepath='.$relativepath)); + dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath)); $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $this->db->rollback(); - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -2; } else { // Call trigger - $result=$this->call_trigger('MYECMDIR_DELETE', $user); + $result = $this->call_trigger('MYECMDIR_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -413,30 +413,30 @@ class EcmDirectory // extends CommonObject if ($mode != 'databaseonly') { - $file = $conf->ecm->dir_output . "/" . $relativepath; + $file = $conf->ecm->dir_output."/".$relativepath; if ($deletedirrecursive) { - $result=@dol_delete_dir_recursive($file, 0, 0); + $result = @dol_delete_dir_recursive($file, 0, 0); } else { - $result=@dol_delete_dir($file, 0); + $result = @dol_delete_dir($file, 0); } } - if ($result || ! @is_dir(dol_osencode($file))) + if ($result || !@is_dir(dol_osencode($file))) { $this->db->commit(); } else { - $this->error='ErrorFailToDeleteDir'; + $this->error = 'ErrorFailToDeleteDir'; dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); $error++; } - if (! $error) return 1; + if (!$error) return 1; else return -1; } @@ -450,11 +450,11 @@ class EcmDirectory // extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->label='MyDirectory'; - $this->fk_parent='0'; - $this->description='This is a directory'; + $this->label = 'MyDirectory'; + $this->fk_parent = '0'; + $this->description = 'This is a directory'; } @@ -472,24 +472,24 @@ class EcmDirectory // extends CommonObject { global $langs; - $result=''; + $result = ''; //$newref=str_replace('_',' ',$this->ref); - $newref=$this->ref; - $label=$langs->trans("ShowECMSection").': '.$newref; - $linkclose='"'.($more?' '.$more:'').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; + $newref = $this->ref; + $label = $langs->trans("ShowECMSection").': '.$newref; + $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = 'picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($max?dol_trunc($newref, $max, 'middle'):$newref); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref); $result .= $linkend; return $result; @@ -505,17 +505,17 @@ class EcmDirectory // extends CommonObject { $this->get_full_arbo($force); - $ret=''; - $idtosearch=$this->id; - $i=0; + $ret = ''; + $idtosearch = $this->id; + $i = 0; do { // Get index cursor in this->cats for id_mere - $cursorindex=-1; + $cursorindex = -1; foreach ($this->cats as $key => $val) { if ($this->cats[$key]['id'] == $idtosearch) { - $cursorindex=$key; + $cursorindex = $key; break; } } @@ -524,13 +524,13 @@ class EcmDirectory // extends CommonObject if ($cursorindex >= 0) { // Path is label sanitized (no space and no special char) and concatenated - $ret=dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret; + $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret; - $idtosearch=$this->cats[$cursorindex]['id_mere']; + $idtosearch = $this->cats[$cursorindex]['id_mere']; $i++; } } - while ($cursorindex >= 0 && ! empty($idtosearch) && $i < 100); // i avoid infinite loop + while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop return $ret; } @@ -546,22 +546,22 @@ class EcmDirectory // extends CommonObject // phpcs:enable global $conf; - $this->motherof=array(); + $this->motherof = array(); // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; - $sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories"; - $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories"; + $sql .= " WHERE fk_parent != 0"; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->motherof[$obj->id_son]=$obj->id_parent; + $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; } @@ -625,7 +625,7 @@ class EcmDirectory // extends CommonObject // phpcs:enable global $conf; - if (empty($force) && ! empty($this->full_arbo_loaded)) + if (empty($force) && !empty($this->full_arbo_loaded)) { return $this->cats; } @@ -635,29 +635,29 @@ class EcmDirectory // extends CommonObject // Charge tableau des categories $sql = "SELECT c.rowid as rowid, c.label as label,"; - $sql.= " c.description as description, c.cachenbofdoc,"; - $sql.= " c.fk_user_c,"; - $sql.= " c.date_c,"; - $sql.= " u.login as login_c,"; - $sql.= " ca.rowid as rowid_fille"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca"; - $sql.= " ON c.rowid = ca.fk_parent"; - $sql.= " WHERE c.fk_user_c = u.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.label, c.rowid"; + $sql .= " c.description as description, c.cachenbofdoc,"; + $sql .= " c.fk_user_c,"; + $sql .= " c.date_c,"; + $sql .= " u.login as login_c,"; + $sql .= " ca.rowid as rowid_fille"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca"; + $sql .= " ON c.rowid = ca.fk_parent"; + $sql .= " WHERE c.fk_user_c = u.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.label, c.rowid"; dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->cats = array(); - $i=0; + $i = 0; // This assignment in condition is not a bug. It allows walking the results. while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['id'] = $obj->rowid; - $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid])?$this->motherof[$obj->rowid]:''); + $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : ''); $this->cats[$obj->rowid]['label'] = $obj->label; $this->cats[$obj->rowid]['description'] = $obj->description; $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc; @@ -665,18 +665,18 @@ class EcmDirectory // extends CommonObject $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c; $this->cats[$obj->rowid]['login_c'] = $obj->login_c; - if (! empty($obj->rowid_fille)) + if (!empty($obj->rowid_fille)) { if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) { - $newelempos=count($this->cats[$obj->rowid]['id_children']); + $newelempos = count($this->cats[$obj->rowid]['id_children']); //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements
    "; - $this->cats[$obj->rowid]['id_children'][$newelempos]=$obj->rowid_fille; + $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille; } else { //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau
    "; - $this->cats[$obj->rowid]['id_children']=array($obj->rowid_fille); + $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille); } } $i++; @@ -689,14 +689,14 @@ class EcmDirectory // extends CommonObject } // We add properties fullxxx to all elements - foreach($this->cats as $key => $val) + foreach ($this->cats as $key => $val) { if (isset($motherof[$key])) continue; $this->build_path_from_id_categ($key, 0); } - $this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); - $this->full_arbo_loaded=1; + $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); + $this->full_arbo_loaded = 1; return $this->cats; } @@ -714,30 +714,30 @@ class EcmDirectory // extends CommonObject { // phpcs:enable // Define fullpath - if (! empty($this->cats[$id_categ]['id_mere'])) + if (!empty($this->cats[$id_categ]['id_mere'])) { - $this->cats[$id_categ]['fullpath'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; - $this->cats[$id_categ]['fullpath'].='_'.$id_categ; - $this->cats[$id_categ]['fullrelativename'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename']; - $this->cats[$id_categ]['fullrelativename'].='/'.$this->cats[$id_categ]['label']; - $this->cats[$id_categ]['fulllabel'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel']; - $this->cats[$id_categ]['fulllabel'].=' >> '.$this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; + $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ; + $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename']; + $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel']; + $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label']; } else { - $this->cats[$id_categ]['fullpath']='_'.$id_categ; - $this->cats[$id_categ]['fullrelativename']=$this->cats[$id_categ]['label']; - $this->cats[$id_categ]['fulllabel']=$this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fullpath'] = '_'.$id_categ; + $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; } // We count number of _ to have level (we use strlen that is faster than dol_strlen) - $this->cats[$id_categ]['level']=strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath'])); + $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath'])); // Traite ces enfants $protection++; - if ($protection > 20) return; // On ne traite pas plus de 20 niveaux + if ($protection > 20) return; // On ne traite pas plus de 20 niveaux if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { - foreach($this->cats[$id_categ]['id_children'] as $key => $val) + foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { $this->build_path_from_id_categ($val, $protection); } @@ -755,34 +755,34 @@ class EcmDirectory // extends CommonObject global $conf; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath(); - $filelist=dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'); + $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath(); + $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'); // Test if filelist is in database // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql.= " cachenbofdoc = '".count($filelist)."'"; + $sql .= " cachenbofdoc = '".count($filelist)."'"; if (empty($all)) // By default { - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; } else { - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " WHERE entity = ".$conf->entity; } dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->cachenbofdoc=count($filelist); + $this->cachenbofdoc = count($filelist); return $this->cachenbofdoc; } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -803,19 +803,19 @@ class EcmDirectory // extends CommonObject public function call_trigger($triggerName, $user) { // phpcs:enable - global $langs,$conf; + global $langs, $conf; - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers($triggerName, $this, $user, $langs, $conf); + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { - $this->errors=array_merge($this->errors, $interface->errors); + $this->errors = array_merge($this->errors, $interface->errors); } else { - $this->errors=$interface->errors; + $this->errors = $interface->errors; } } return $result; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 01f6228ad83..0c7c4c4cebb 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -27,7 +27,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Class to manage ECM files @@ -60,7 +60,7 @@ class EcmFiles extends CommonObject */ public $label; - public $share; // hash for file sharing, empty by default (example: getRandomPassword(true)) + public $share; // hash for file sharing, empty by default (example: getRandomPassword(true)) /** * @var int Entity @@ -79,7 +79,7 @@ class EcmFiles extends CommonObject public $keywords; public $cover; public $position; - public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' + public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' public $extraparams; public $date_c = ''; public $date_m = ''; @@ -142,7 +142,7 @@ class EcmFiles extends CommonObject } if (isset($this->filepath)) { $this->filepath = trim($this->filepath); - $this->filepath = preg_replace('/[\\/]+$/', '', $this->filepath); // Remove last / + $this->filepath = preg_replace('/[\\/]+$/', '', $this->filepath); // Remove last / } if (isset($this->fullpath_orig)) { $this->fullpath_orig = trim($this->fullpath_orig); @@ -179,20 +179,20 @@ class EcmFiles extends CommonObject // If ref not defined $ref = ''; - if (! empty($this->ref)) + if (!empty($this->ref)) { - $ref=$this->ref; + $ref = $this->ref; } else { include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; $ref = dol_hash($this->filepath.'/'.$this->filename, 3); } - $maxposition=0; + $maxposition = 0; if (empty($this->position)) // Get max used { - $sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql.= " WHERE filepath ='".$this->db->escape($this->filepath)."'"; + $sql = "SELECT MAX(position) as maxposition FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE filepath ='".$this->db->escape($this->filepath)."'"; $resql = $this->db->query($sql); if ($resql) @@ -202,14 +202,14 @@ class EcmFiles extends CommonObject } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); + $this->errors[] = 'Error '.$this->db->lasterror(); return --$error; } - $maxposition=$maxposition+1; + $maxposition = $maxposition + 1; } else { - $maxposition=$this->position; + $maxposition = $this->position; } // Check parameters @@ -218,75 +218,75 @@ class EcmFiles extends CommonObject $this->errors[] = 'Bad property filename or filepath'; return --$error; } - if (! isset($this->entity)) + if (!isset($this->entity)) { $this->entity = $conf->entity; } // Put here code to add control on parameters values // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'ref,'; - $sql.= 'label,'; - $sql.= 'share,'; - $sql.= 'entity,'; - $sql.= 'filename,'; - $sql.= 'filepath,'; - $sql.= 'fullpath_orig,'; - $sql.= 'description,'; - $sql.= 'keywords,'; - $sql.= 'cover,'; - $sql.= 'position,'; - $sql.= 'gen_or_uploaded,'; - $sql.= 'extraparams,'; - $sql.= 'date_c,'; - $sql.= 'date_m,'; - $sql.= 'fk_user_c,'; - $sql.= 'fk_user_m,'; - $sql.= 'acl,'; - $sql.= 'src_object_type,'; - $sql.= 'src_object_id'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; + $sql .= 'ref,'; + $sql .= 'label,'; + $sql .= 'share,'; + $sql .= 'entity,'; + $sql .= 'filename,'; + $sql .= 'filepath,'; + $sql .= 'fullpath_orig,'; + $sql .= 'description,'; + $sql .= 'keywords,'; + $sql .= 'cover,'; + $sql .= 'position,'; + $sql .= 'gen_or_uploaded,'; + $sql .= 'extraparams,'; + $sql .= 'date_c,'; + $sql .= 'date_m,'; + $sql .= 'fk_user_c,'; + $sql .= 'fk_user_m,'; + $sql .= 'acl,'; + $sql .= 'src_object_type,'; + $sql .= 'src_object_id'; $sql .= ') VALUES ('; $sql .= " '".$ref."', "; - $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").','; - $sql .= ' '.(! isset($this->share)?'NULL':"'".$this->db->escape($this->share)."'").','; + $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; + $sql .= ' '.(!isset($this->share) ? 'NULL' : "'".$this->db->escape($this->share)."'").','; $sql .= ' '.$this->entity.','; - $sql .= ' '.(! isset($this->filename)?'NULL':"'".$this->db->escape($this->filename)."'").','; - $sql .= ' '.(! isset($this->filepath)?'NULL':"'".$this->db->escape($this->filepath)."'").','; - $sql .= ' '.(! isset($this->fullpath_orig)?'NULL':"'".$this->db->escape($this->fullpath_orig)."'").','; - $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; - $sql .= ' '.(! isset($this->keywords)?'NULL':"'".$this->db->escape($this->keywords)."'").','; - $sql .= ' '.(! isset($this->cover)?'NULL':"'".$this->db->escape($this->cover)."'").','; + $sql .= ' '.(!isset($this->filename) ? 'NULL' : "'".$this->db->escape($this->filename)."'").','; + $sql .= ' '.(!isset($this->filepath) ? 'NULL' : "'".$this->db->escape($this->filepath)."'").','; + $sql .= ' '.(!isset($this->fullpath_orig) ? 'NULL' : "'".$this->db->escape($this->fullpath_orig)."'").','; + $sql .= ' '.(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(!isset($this->keywords) ? 'NULL' : "'".$this->db->escape($this->keywords)."'").','; + $sql .= ' '.(!isset($this->cover) ? 'NULL' : "'".$this->db->escape($this->cover)."'").','; $sql .= ' '.$maxposition.','; - $sql .= ' '.(! isset($this->gen_or_uploaded)?'NULL':"'".$this->db->escape($this->gen_or_uploaded)."'").','; - $sql .= ' '.(! isset($this->extraparams)?'NULL':"'".$this->db->escape($this->extraparams)."'").','; + $sql .= ' '.(!isset($this->gen_or_uploaded) ? 'NULL' : "'".$this->db->escape($this->gen_or_uploaded)."'").','; + $sql .= ' '.(!isset($this->extraparams) ? 'NULL' : "'".$this->db->escape($this->extraparams)."'").','; $sql .= ' '."'".$this->db->idate($this->date_c)."'".','; - $sql .= ' '.(! isset($this->date_m) || dol_strlen($this->date_m)==0?'NULL':"'".$this->db->idate($this->date_m)."'").','; - $sql .= ' '.(! isset($this->fk_user_c)?$user->id:$this->fk_user_c).','; - $sql .= ' '.(! isset($this->fk_user_m)?'NULL':$this->fk_user_m).','; - $sql .= ' '.(! isset($this->acl)?'NULL':"'".$this->db->escape($this->acl)."'").','; - $sql .= ' '.(! isset($this->src_object_type)?'NULL':"'".$this->db->escape($this->src_object_type)."'").','; - $sql .= ' '.(! isset($this->src_object_id)?'NULL':$this->src_object_id); + $sql .= ' '.(!isset($this->date_m) || dol_strlen($this->date_m) == 0 ? 'NULL' : "'".$this->db->idate($this->date_m)."'").','; + $sql .= ' '.(!isset($this->fk_user_c) ? $user->id : $this->fk_user_c).','; + $sql .= ' '.(!isset($this->fk_user_m) ? 'NULL' : $this->fk_user_m).','; + $sql .= ' '.(!isset($this->acl) ? 'NULL' : "'".$this->db->escape($this->acl)."'").','; + $sql .= ' '.(!isset($this->src_object_type) ? 'NULL' : "'".$this->db->escape($this->src_object_type)."'").','; + $sql .= ' '.(!isset($this->src_object_id) ? 'NULL' : $this->src_object_id); $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->position = $maxposition; // Triggers - if (! $notrigger) + if (!$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); + $result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -296,7 +296,7 @@ class EcmFiles extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -344,25 +344,25 @@ class EcmFiles extends CommonObject $sql .= " t.acl,"; $sql .= " t.src_object_type,"; $sql .= " t.src_object_id"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - $sql.= ' WHERE 1 = 1'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE 1 = 1'; /* Fetching this table depends on filepath+filename, it must not depends on entity if (! empty($conf->multicompany->enabled)) { $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; }*/ if ($relativepath) { - $sql .= " AND t.filepath = '" . $this->db->escape(dirname($relativepath)) . "' AND t.filename = '".$this->db->escape(basename($relativepath))."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + $sql .= " AND t.filepath = '".$this->db->escape(dirname($relativepath))."' AND t.filename = '".$this->db->escape(basename($relativepath))."'"; + $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index } - elseif (! empty($ref)) { // hash of file path + elseif (!empty($ref)) { // hash of file path $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index } - elseif (! empty($hashoffile)) { // hash of content + elseif (!empty($hashoffile)) { // hash of content $sql .= " AND t.label = '".$this->db->escape($hashoffile)."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index } - elseif (! empty($hashforshare)) { + elseif (!empty($hashforshare)) { $sql .= " AND t.share = '".$this->db->escape($hashforshare)."'"; //$sql .= " AND t.entity = ".$conf->entity; // hashforshare already unique } @@ -373,10 +373,10 @@ class EcmFiles extends CommonObject $sql .= " AND t.entity = ".$conf->entity; } else { - $sql .= ' AND t.rowid = '.$this->db->escape($id); // rowid already unique + $sql .= ' AND t.rowid = '.$this->db->escape($id); // rowid already unique } - $this->db->plimit(1); // When we search on src or on hash of content (hashforfile) to solve hash conflict when several files has same content, we take first one only + $this->db->plimit(1); // When we search on src or on hash of content (hashforfile) to solve hash conflict when several files has same content, we take first one only $this->db->order('t.rowid', 'ASC'); $resql = $this->db->query($sql); @@ -422,8 +422,8 @@ class EcmFiles extends CommonObject return 0; } } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); return -1; } @@ -466,28 +466,28 @@ class EcmFiles extends CommonObject $sql .= " t.acl,"; $sql .= " t.src_object_type,"; $sql .= " t.src_object_id"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } - $sql.= ' WHERE 1 = 1'; + $sql .= ' WHERE 1 = 1'; /* Fetching this table depends on filepath+filename, it must not depends on entity if (! empty($conf->multicompany->enabled)) { $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; }*/ if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $this->lines = array(); @@ -526,10 +526,10 @@ class EcmFiles extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -601,42 +601,42 @@ class EcmFiles extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql .= " ref = '".dol_hash($this->filepath.'/'.$this->filename, 3)."',"; - $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").','; - $sql .= ' share = '.(! empty($this->share)?"'".$this->db->escape($this->share)."'":"null").','; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:$conf->entity).','; - $sql .= ' filename = '.(isset($this->filename)?"'".$this->db->escape($this->filename)."'":"null").','; - $sql .= ' filepath = '.(isset($this->filepath)?"'".$this->db->escape($this->filepath)."'":"null").','; - $sql .= ' fullpath_orig = '.(isset($this->fullpath_orig)?"'".$this->db->escape($this->fullpath_orig)."'":"null").','; - $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; - $sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").','; - $sql .= ' cover = '.(isset($this->cover)?"'".$this->db->escape($this->cover)."'":"null").','; - $sql .= ' position = '.(isset($this->position)?$this->db->escape($this->position):"0").','; - $sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded)?"'".$this->db->escape($this->gen_or_uploaded)."'":"null").','; - $sql .= ' extraparams = '.(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").','; - $sql .= ' date_c = '.(! isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').','; + $sql .= ' label = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; + $sql .= ' share = '.(!empty($this->share) ? "'".$this->db->escape($this->share)."'" : "null").','; + $sql .= ' entity = '.(isset($this->entity) ? $this->entity : $conf->entity).','; + $sql .= ' filename = '.(isset($this->filename) ? "'".$this->db->escape($this->filename)."'" : "null").','; + $sql .= ' filepath = '.(isset($this->filepath) ? "'".$this->db->escape($this->filepath)."'" : "null").','; + $sql .= ' fullpath_orig = '.(isset($this->fullpath_orig) ? "'".$this->db->escape($this->fullpath_orig)."'" : "null").','; + $sql .= ' description = '.(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").','; + $sql .= ' keywords = '.(isset($this->keywords) ? "'".$this->db->escape($this->keywords)."'" : "null").','; + $sql .= ' cover = '.(isset($this->cover) ? "'".$this->db->escape($this->cover)."'" : "null").','; + $sql .= ' position = '.(isset($this->position) ? $this->db->escape($this->position) : "0").','; + $sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded) ? "'".$this->db->escape($this->gen_or_uploaded)."'" : "null").','; + $sql .= ' extraparams = '.(isset($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").','; + $sql .= ' date_c = '.(!isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').','; //$sql .= ' date_m = '.(! isset($this->date_m) || dol_strlen($this->date_m) != 0 ? "'".$this->db->idate($this->date_m)."'" : 'null').','; // Field automatically updated - $sql .= ' fk_user_m = '.($this->fk_user_m > 0?$this->fk_user_m:$user->id).','; - $sql .= ' acl = '.(isset($this->acl)?"'".$this->db->escape($this->acl)."'":"null").','; - $sql .= ' src_object_id = '.($this->src_object_id > 0?$this->src_object_id:"null").','; - $sql .= ' src_object_type = '.(isset($this->src_object_type)?"'".$this->db->escape($this->src_object_type)."'":"null"); - $sql .= ' WHERE rowid=' . $this->id; + $sql .= ' fk_user_m = '.($this->fk_user_m > 0 ? $this->fk_user_m : $user->id).','; + $sql .= ' acl = '.(isset($this->acl) ? "'".$this->db->escape($this->acl)."'" : "null").','; + $sql .= ' src_object_id = '.($this->src_object_id > 0 ? $this->src_object_id : "null").','; + $sql .= ' src_object_type = '.(isset($this->src_object_type) ? "'".$this->db->escape($this->src_object_type)."'" : "null"); + $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } // Triggers - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); + $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -645,7 +645,7 @@ class EcmFiles extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -670,10 +670,10 @@ class EcmFiles extends CommonObject $this->db->begin(); // Triggers - if (! $notrigger) + if (!$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); + $result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -681,14 +681,14 @@ class EcmFiles extends CommonObject // If you need to delete child tables to, you can insert them here if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' WHERE rowid='.$this->id; $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } } @@ -696,7 +696,7 @@ class EcmFiles extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -734,9 +734,9 @@ class EcmFiles extends CommonObject // Other options if ($result < 0) { - $error ++; + $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } unset($object->context['createfromclone']); @@ -749,7 +749,7 @@ class EcmFiles extends CommonObject } else { $this->db->rollback(); - return - 1; + return -1; } } @@ -769,40 +769,40 @@ class EcmFiles extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("MyModule") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("MyModule").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowProject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowProject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = '
    '; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; if ($withpicto) { - $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result.=' '; + $result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend); + if ($withpicto != 2) $result .= ' '; } - $result.= $linkstart . $this->ref . $linkend; + $result .= $linkstart.$this->ref.$linkend; return $result; } @@ -841,7 +841,7 @@ class EcmFiles extends CommonObject */ public function initAsSpecimen() { - global $conf,$user; + global $conf, $user; $this->id = 0; @@ -891,7 +891,7 @@ class EcmfilesLine public $keywords; public $cover; public $position; - public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' + public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' public $extraparams; public $date_c = ''; public $date_m = ''; diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 92cee2570bc..de9f289eb79 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -35,7 +35,7 @@ class FormEcm /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -62,9 +62,9 @@ class FormEcm global $conf, $langs; $langs->load("ecm"); - if ($select_name=='') $select_name="catParent"; + if ($select_name == '') $select_name = "catParent"; - $cate_arbo=null; + $cate_arbo = null; if ($module == 'ecm') { $cat = new EcmDirectory($this->db); @@ -74,17 +74,17 @@ class FormEcm { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $path = $conf->medias->multidir_output[$conf->entity]; - $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$','^\.'), 'relativename', SORT_ASC); + $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); } $output = ''; - $output.=ajax_combobox($select_name); - $output.= "\n"; + $output .= ''; + $output .= ajax_combobox($select_name); + $output .= "\n"; return $output; } } diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index 979d4cf2709..0c9190b9a4c 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts","categories")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts", "categories")); // Get parameters $socid = GETPOST('socid', 'int'); @@ -41,7 +41,7 @@ $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module='ecm'; +if (empty($module)) $module = 'ecm'; // Security check if ($user->socid > 0) @@ -50,8 +50,8 @@ if ($user->socid > 0) $socid = $user->socid; } -$section=$urlsection=GETPOST('section', 'alpha'); -if (empty($urlsection)) $urlsection='misc'; +$section = $urlsection = GETPOST('section', 'alpha'); +if (empty($urlsection)) $urlsection = 'misc'; if ($module == 'ecm') { @@ -69,14 +69,14 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="label"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "label"; $ecmdir = new EcmDirectory($db); -if (! empty($section)) +if (!empty($section)) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; @@ -97,7 +97,7 @@ if ($module == 'medias') $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); } -if (! $permtoadd) accessforbidden(); +if (!$permtoadd) accessforbidden(); @@ -110,14 +110,14 @@ if ($action == 'add' && $permtoadd) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { - header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module?'&module='.$module:'')); + header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module ? '&module='.$module : '')); exit; } } @@ -125,10 +125,10 @@ if ($action == 'add' && $permtoadd) $ref = trim(GETPOST("ref", 'alpha')); $label = trim(GETPOST("label", 'alpha')); $desc = trim(GETPOST("desc", 'alpha')); - $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) - if ($catParent == '-1') $catParent=0; + $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) + if ($catParent == '-1') $catParent = 0; - $error=0; + $error = 0; if (empty($label)) { @@ -137,7 +137,7 @@ if ($action == 'add' && $permtoadd) $error++; } - if (! $error) + if (!$error) { if ($module == 'ecm') { @@ -168,9 +168,9 @@ if ($action == 'add' && $permtoadd) dol_print_error('', 'Bad value for module. Not supported.'); } - if (! $error) + if (!$error) { - $fullpathofdir = $dirfornewdir.'/'.($catParent? $catParent.'/' : '').$label; + $fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label; $result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT); if ($result < 0) { @@ -185,9 +185,9 @@ if ($action == 'add' && $permtoadd) } } - if (! $error) + if (!$error) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -203,7 +203,7 @@ if ($action == 'add' && $permtoadd) // Deleting file elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { - $result=$ecmdir->delete($user); + $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); } @@ -216,8 +216,8 @@ elseif ($action == 'confirm_deletesection' && $confirm == 'yes') llxHeader('', $langs->trans("ECMNewSection")); -$form=new Form($db); -$formecm=new FormEcm($db); +$form = new Form($db); +$formecm = new FormEcm($db); if ($action == 'create') { @@ -232,7 +232,7 @@ if ($action == 'create') if ($website) print ''; if ($pageid) print ''; - $title=$langs->trans("ECMNewSection"); + $title = $langs->trans("ECMNewSection"); print load_fiche_titre($title); dol_fiche_head(); diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 3793be8a784..42c6b140f3c 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module='ecm'; +if (empty($module)) $module = 'ecm'; // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); @@ -49,11 +49,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; -$section=GETPOST("section", 'alpha')?GETPOST("section", 'alpha'):GETPOST("relativedir", 'alpha'); -if (! $section) +$section = GETPOST("section", 'alpha') ?GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha'); +if (!$section) { dol_print_error('', "ErrorSectionParamNotDefined"); exit; @@ -64,14 +64,14 @@ $ecmdir = new EcmDirectory($db); if ($module == 'ecm') { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; } else // For example $module == 'medias' @@ -101,14 +101,14 @@ if ($module == 'medias') */ // Upload file -if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) { if (dol_mkdir($upload_dir) >= 0) { - $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); + $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $result=$ecmdir->changeNbOfFiles('+'); + $result = $ecmdir->changeNbOfFiles('+'); } else { @@ -138,12 +138,12 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($action == 'confirm_deletefile' && $confirm == 'yes') { $langs->load("other"); - $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($file); + $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $result=$ecmdir->changeNbOfFiles('-'); + $result = $ecmdir->changeNbOfFiles('-'); } // Remove dir @@ -160,7 +160,7 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') if ($module == 'ecm') { // Fetch was already done - $result=$ecmdir->delete($user, 'all', $deletedirrecursive); + $result = $ecmdir->delete($user, 'all', $deletedirrecursive); if ($result <= 0) { $langs->load('errors'); @@ -193,20 +193,20 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') } // Update dirname or description -if ($action == 'update' && ! GETPOST('cancel', 'alpha')) +if ($action == 'update' && !GETPOST('cancel', 'alpha')) { - $error=0; + $error = 0; if ($module == 'ecm') { - $oldlabel=$ecmdir->label; - $olddir=$ecmdir->getRelativePath(0); - $olddir=$conf->ecm->dir_output.'/'.$olddir; + $oldlabel = $ecmdir->label; + $olddir = $ecmdir->getRelativePath(0); + $olddir = $conf->ecm->dir_output.'/'.$olddir; } else { - $olddir=GETPOST('section', 'alpha'); - $olddir=$conf->medias->multidir_output[$conf->entity].'/'.$relativepath; + $olddir = GETPOST('section', 'alpha'); + $olddir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; } if ($module == 'ecm') @@ -216,17 +216,17 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) // Fetch was already done $ecmdir->label = dol_sanitizeFileName(GETPOST("label")); $ecmdir->description = GETPOST("description"); - $result=$ecmdir->update($user); + $result = $ecmdir->update($user); if ($result > 0) { // Try to rename file if changed - if ($oldlabel != $ecmdir->label && file_exists($olddir)) + if ($oldlabel != $ecmdir->label && file_exists($olddir)) { - $newdir=$ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory - $newdir=$conf->ecm->dir_output.'/'.$newdir; + $newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory + $newdir = $conf->ecm->dir_output.'/'.$newdir; //print $olddir.'-'.$newdir; - $result=@rename($olddir, $newdir); - if (! $result) + $result = @rename($olddir, $newdir); + if (!$result) { $langs->load('errors'); setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors'); @@ -234,12 +234,12 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) } } - if (! $error) + if (!$error) { $db->commit(); // Set new value after renaming - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; } else @@ -257,18 +257,18 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) { $newdir = $conf->medias->multidir_output[$conf->entity].'/'.GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); - $result=@rename($olddir, $newdir); - if (! $result) + $result = @rename($olddir, $newdir); + if (!$result) { $langs->load('errors'); setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors'); $error++; } - if (! $error) + if (!$error) { // Set new value after renaming - $relativepath=GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); + $relativepath = GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); $upload_dir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; $section = $relativepath; } @@ -281,9 +281,9 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) * View ********************************************************************/ -$form=new Form($db); +$form = new Form($db); -$object=new EcmDirectory($db); // Need to create a new one instance +$object = new EcmDirectory($db); // Need to create a new one instance if ($module == 'ecm') { @@ -293,12 +293,12 @@ if ($module == 'ecm') llxHeader(); // Built the file List -$filearrayall=dol_dir_list($upload_dir, "all", 0, '', '', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); -$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); -$totalsize=0; -foreach($filearray as $key => $file) +$filearrayall = dol_dir_list($upload_dir, "all", 0, '', '', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); +$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); +$totalsize = 0; +foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } @@ -316,33 +316,33 @@ if ($action == 'edit') } -$morehtml=''; +$morehtml = ''; $morehtmlref = '/'.$module.'/'.$relativepath; if ($module == 'ecm') { - $s=''; + $s = ''; $result = 1; - $i=0; - $tmpecmdir=new EcmDirectory($db); // Need to create a new one + $i = 0; + $tmpecmdir = new EcmDirectory($db); // Need to create a new one $tmpecmdir->fetch($ecmdir->id); while ($tmpecmdir && $result > 0) { - $tmpecmdir->ref=$tmpecmdir->label; + $tmpecmdir->ref = $tmpecmdir->label; if ($i == 0 && $action == 'edit') { - $s=''; + $s = ''; } - else $s=$tmpecmdir->getNomUrl(1).$s; + else $s = $tmpecmdir->getNomUrl(1).$s; if ($tmpecmdir->fk_parent) { - $s=' -> '.$s; - $result=$tmpecmdir->fetch($tmpecmdir->fk_parent); + $s = ' -> '.$s; + $result = $tmpecmdir->fetch($tmpecmdir->fk_parent); } else { - $tmpecmdir=0; + $tmpecmdir = 0; } $i++; } @@ -351,25 +351,25 @@ if ($module == 'ecm') } if ($module == 'medias') { - $s='medias -> '; + $s = 'medias -> '; $result = 1; - $subdirs=explode('/', $section); - $i=0; - foreach($subdirs as $subdir) + $subdirs = explode('/', $section); + $i = 0; + foreach ($subdirs as $subdir) { if ($i == (count($subdirs) - 1)) { if ($action == 'edit') { - $s.=''; - $s.=''; - $s.=''; + $s .= ''; + $s .= ''; + $s .= ''; } - else $s.=$subdir; + else $s .= $subdir; } if ($i < (count($subdirs) - 1)) { - $s.=$subdir.' -> '; + $s .= $subdir.' -> '; } $i++; } @@ -401,7 +401,7 @@ if ($module == 'ecm') print ''; print ''.$langs->trans("ECMCreationUser").''; - $userecm=new User($db); + $userecm = new User($db); $userecm->fetch($ecmdir->fk_user_c); print $userecm->getNomUrl(1); print ''; @@ -428,7 +428,7 @@ else } print ''; print ''.$langs->trans("ECMNbOfDocs").''; -$nbofiles=count($filearray); +$nbofiles = count($filearray); print $nbofiles; if ($ecmdir->id > 0) { @@ -470,12 +470,12 @@ if ($action != 'edit' && $action != 'delete') if ($permtoadd) { - print ''.$langs->trans('Edit').''; + print ''.$langs->trans('Edit').''; } if ($permtoadd) { - print ''.$langs->trans('ECMAddSection').''; + print ''.$langs->trans('ECMAddSection').''; } else { @@ -486,7 +486,7 @@ if ($action != 'edit' && $action != 'delete') //{ if ($permtoadd) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { @@ -512,18 +512,18 @@ if ($action == 'delete') // Confirm remove file if ($action == 'delete_dir') { - $relativepathwithoutslash=preg_replace('/[\/]$/', '', $relativepath); + $relativepathwithoutslash = preg_replace('/[\/]$/', '', $relativepath); //Form to close proposal (signed or not) if (count($filearrayall) > 0) { $langs->load("other"); $formquestion = array( - array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
    '.$langs->trans("DeleteAlsoContentRecursively"),'value' => '0') // Field to complete private note (not replace) + array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
    '.$langs->trans("DeleteAlsoContentRecursively"), 'value' => '0') // Field to complete private note (not replace) ); } - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section', 'alpha').($module?'&module='.$module:'').($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section', 'alpha').($module ? '&module='.$module : '').($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); } diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index e88417c526a..9e51da09899 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -32,18 +32,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ecm', 0); // Get parameters -$socid=GETPOST('socid', 'int'); -$action=GETPOST('action', 'aZ09'); -$section=GETPOST('section', 'int')?GETPOST('section', 'int'):GETPOST('section_id', 'int'); -if (! $section) $section=0; -$section_dir=GETPOST('section_dir', 'alpha'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'aZ09'); +$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int'); +if (!$section) $section = 0; +$section_dir = GETPOST('section_dir', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -52,25 +52,25 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="fullname"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "fullname"; $ecmdir = new EcmDirectory($db); if ($section) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } } -$form=new Form($db); +$form = new Form($db); $ecmdirstatic = new EcmDirectory($db); $userstatic = new User($db); -$error=0; +$error = 0; /* @@ -82,23 +82,23 @@ $error=0; //include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // Upload file (code similar but different than actions_linkedfiles.inc.php) -if (GETPOST("sendit", 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST("sendit", 'none') && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Define relativepath and upload_dir - $relativepath=''; - if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath(); - else $relativepath=$section_dir; + $relativepath = ''; + if ($ecmdir->id) $relativepath = $ecmdir->getRelativePath(); + else $relativepath = $section_dir; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; - else $userfiles=array($_FILES['userfile']['tmp_name']); + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; + else $userfiles = array($_FILES['userfile']['tmp_name']); - foreach($userfiles as $key => $userfile) + foreach ($userfiles as $key => $userfile) { if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; - if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); } else { @@ -107,13 +107,13 @@ if (GETPOST("sendit", 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } - if (! $error) + if (!$error) { $generatethumbs = 0; $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); if ($res > 0) { - $result=$ecmdir->changeNbOfFiles('+'); + $result = $ecmdir->changeNbOfFiles('+'); } } } @@ -126,14 +126,14 @@ if ($action == 'confirm_deletefile') // GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections. //var_dump(GETPOST('urlfile'));exit; - $upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:''); - $file = $upload_dir . "/" . GETPOST('urlfile', 'alpha'); + $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); + $file = $upload_dir."/".GETPOST('urlfile', 'alpha'); - $ret=dol_delete_file($file); // This include also the delete from file index in database. + $ret = dol_delete_file($file); // This include also the delete from file index in database. if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs'); - $result=$ecmdir->changeNbOfFiles('-'); + $result = $ecmdir->changeNbOfFiles('-'); } else { @@ -142,7 +142,7 @@ if ($action == 'confirm_deletefile') clearstatcache(); } - $action='file_manager'; + $action = 'file_manager'; } // Add directory @@ -170,7 +170,7 @@ if ($action == 'add' && $user->rights->ecm->setup) // Remove directory if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') { - $result=$ecmdir->delete($user); + $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); clearstatcache(); @@ -186,56 +186,56 @@ if ($action == 'refreshmanual') // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); - $diroutputslash=str_replace('\\', '/', $conf->ecm->dir_output); - $diroutputslash.='/'; + $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); + $diroutputslash .= '/'; // Scan directory tree on disk - $disktree=dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); + $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); // Scan directory tree in database - $sqltree=$ecmdirstatic->get_full_arbo(0); + $sqltree = $ecmdirstatic->get_full_arbo(0); - $adirwascreated=0; + $adirwascreated = 0; // Now we compare both trees to complete missing trees into database //var_dump($disktree); //var_dump($sqltree); - foreach($disktree as $dirdesc) // Loop on tree onto disk + foreach ($disktree as $dirdesc) // Loop on tree onto disk { - $dirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) { - $dirisindatabase=1; + $dirisindatabase = 1; break; } } - if (! $dirisindatabase) + if (!$dirisindatabase) { - $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); //print $txt."
    \n"; // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent=-1; - $relativepathmissing=str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent=$relativepathmissing; + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); if (preg_match('/\//', $relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent)) { - $relativepathtosearchparent=preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; dol_syslog($txt); //print $txt." -> "; - $parentdirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) { - $parentdirisindatabase=$dirsqldesc['id']; + $parentdirisindatabase = $dirsqldesc['id']; break; } } @@ -243,7 +243,7 @@ if ($action == 'refreshmanual') { dol_syslog("Yes with id ".$parentdirisindatabase); //print "Yes with id ".$parentdirisindatabase."
    \n"; - $fk_parent=$parentdirisindatabase; + $fk_parent = $parentdirisindatabase; //break; // We found parent, we can stop the while loop } else @@ -255,7 +255,7 @@ if ($action == 'refreshmanual') else { dol_syslog("Parent is root"); - $fk_parent=0; // Parent is root + $fk_parent = 0; // Parent is root } if ($fk_parent >= 0) @@ -265,20 +265,20 @@ if ($action == 'refreshmanual') $ecmdirtmp->description = ''; $ecmdirtmp->fk_parent = $fk_parent; - $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $ecmdirtmp->cachenbofdoc."
    \n";exit; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql=array('id'=>$id, + $newdirsql = array('id'=>$id, 'id_mere'=>$ecmdirtmp->fk_parent, 'label'=>$ecmdirtmp->label, 'description'=>$ecmdirtmp->description, 'fullrelativename'=>$relativepathmissing); - $sqltree[]=$newdirsql; // We complete fulltree for following loops + $sqltree[] = $newdirsql; // We complete fulltree for following loops //var_dump($sqltree); - $adirwascreated=1; + $adirwascreated = 1; } else { @@ -286,7 +286,7 @@ if ($action == 'refreshmanual') } } else { - $txt="Parent of ".$dirdesc['fullname']." not found"; + $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); //print $txt."
    \n"; } @@ -294,24 +294,24 @@ if ($action == 'refreshmanual') } // Loop now on each sql tree to check if dir exists - foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk { - $dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; - if (! dol_is_dir($dirtotest)) + $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + if (!dol_is_dir($dirtotest)) { - $ecmdirtmp->id=$dirdesc['id']; + $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } } - $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean // it to be sure that fulltree array is not used without reloading it. - if ($adirwascreated) $sqltree=null; + if ($adirwascreated) $sqltree = null; } @@ -322,18 +322,18 @@ if ($action == 'refreshmanual') // Define height of file area (depends on $_SESSION["dol_screenheight"]) //print $_SESSION["dol_screenheight"]; -$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index_auto.php file +$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index_auto.php file -$moreheadcss=''; -$moreheadjs=''; +$moreheadcss = ''; +$moreheadjs = ''; //$morejs=array(); -$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; -$moreheadjs.=''."\n"; +$moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); @@ -342,7 +342,7 @@ dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECM // Add filemanager component -$module='ecm'; +$module = 'ecm'; include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; // End of page diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index be3cc7a372c..6c245e3ad1c 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -31,21 +31,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ecm', 0); // Get parameters -$socid=GETPOST('socid', 'int'); -$action=GETPOST('action', 'aZ09'); -$section=GETPOST('section', 'int')?GETPOST('section', 'int'):GETPOST('section_id', 'int'); -$module=GETPOST('module', 'alpha'); -if (! $section) $section=0; -$section_dir=GETPOST('section_dir', 'alpha'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'aZ09'); +$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int'); +$module = GETPOST('module', 'alpha'); +if (!$section) $section = 0; +$section_dir = GETPOST('section_dir', 'alpha'); -$search_doc_ref=GETPOST('search_doc_ref', 'alpha'); +$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -54,26 +54,26 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="fullname"; -if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield="level1name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "fullname"; +if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield = "level1name"; $ecmdir = new EcmDirectory($db); if ($section) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } } -$form=new Form($db); +$form = new Form($db); $ecmdirstatic = new EcmDirectory($db); $userstatic = new User($db); -$error=0; +$error = 0; /* @@ -83,7 +83,7 @@ $error=0; // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_doc_ref=''; + $search_doc_ref = ''; } @@ -119,33 +119,33 @@ if ($action == 'confirm_deletefile') $langs->load("other"); if ($section) { - $result=$ecmdir->fetch($section); - if (! ($result > 0)) + $result = $ecmdir->fetch($section); + if (!($result > 0)) { dol_print_error($db, $ecmdir->error); exit; } - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); } - else $relativepath=''; - $upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:''); - $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). + else $relativepath = ''; + $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); + $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). - $ret=dol_delete_file($file); + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $result=$ecmdir->changeNbOfFiles('-'); + $result = $ecmdir->changeNbOfFiles('-'); clearstatcache(); } - $action='file_manager'; + $action = 'file_manager'; } // Remove directory if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') { - $result=$ecmdir->delete($user); + $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); clearstatcache(); @@ -161,56 +161,56 @@ if ($action == 'refreshmanual') // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); - $diroutputslash=str_replace('\\', '/', $conf->ecm->dir_output); - $diroutputslash.='/'; + $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); + $diroutputslash .= '/'; // Scan directory tree on disk - $disktree=dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); + $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); // Scan directory tree in database - $sqltree=$ecmdirstatic->get_full_arbo(0); + $sqltree = $ecmdirstatic->get_full_arbo(0); - $adirwascreated=0; + $adirwascreated = 0; // Now we compare both trees to complete missing trees into database //var_dump($disktree); //var_dump($sqltree); - foreach($disktree as $dirdesc) // Loop on tree onto disk + foreach ($disktree as $dirdesc) // Loop on tree onto disk { - $dirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) { - $dirisindatabase=1; + $dirisindatabase = 1; break; } } - if (! $dirisindatabase) + if (!$dirisindatabase) { - $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); //print $txt."
    \n"; // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent=-1; - $relativepathmissing=str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent=$relativepathmissing; + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); if (preg_match('/\//', $relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent)) { - $relativepathtosearchparent=preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; dol_syslog($txt); //print $txt." -> "; - $parentdirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) { - $parentdirisindatabase=$dirsqldesc['id']; + $parentdirisindatabase = $dirsqldesc['id']; break; } } @@ -218,7 +218,7 @@ if ($action == 'refreshmanual') { dol_syslog("Yes with id ".$parentdirisindatabase); //print "Yes with id ".$parentdirisindatabase."
    \n"; - $fk_parent=$parentdirisindatabase; + $fk_parent = $parentdirisindatabase; //break; // We found parent, we can stop the while loop } else @@ -230,7 +230,7 @@ if ($action == 'refreshmanual') else { dol_syslog("Parent is root"); - $fk_parent=0; // Parent is root + $fk_parent = 0; // Parent is root } if ($fk_parent >= 0) @@ -240,20 +240,20 @@ if ($action == 'refreshmanual') $ecmdirtmp->description = ''; $ecmdirtmp->fk_parent = $fk_parent; - $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $ecmdirtmp->cachenbofdoc."
    \n";exit; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql=array('id'=>$id, + $newdirsql = array('id'=>$id, 'id_mere'=>$ecmdirtmp->fk_parent, 'label'=>$ecmdirtmp->label, 'description'=>$ecmdirtmp->description, 'fullrelativename'=>$relativepathmissing); - $sqltree[]=$newdirsql; // We complete fulltree for following loops + $sqltree[] = $newdirsql; // We complete fulltree for following loops //var_dump($sqltree); - $adirwascreated=1; + $adirwascreated = 1; } else { @@ -261,7 +261,7 @@ if ($action == 'refreshmanual') } } else { - $txt="Parent of ".$dirdesc['fullname']." not found"; + $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); //print $txt."
    \n"; } @@ -269,24 +269,24 @@ if ($action == 'refreshmanual') } // Loop now on each sql tree to check if dir exists - foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk { - $dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; - if (! dol_is_dir($dirtotest)) + $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + if (!dol_is_dir($dirtotest)) { - $ecmdirtmp->id=$dirdesc['id']; + $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } } - $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean // it to be sure that fulltree array is not used without reloading it. - if ($adirwascreated) $sqltree=null; + if ($adirwascreated) $sqltree = null; } @@ -297,43 +297,43 @@ if ($action == 'refreshmanual') // Define height of file area (depends on $_SESSION["dol_screenheight"]) //print $_SESSION["dol_screenheight"]; -$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index.php file +$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index.php file -$moreheadcss=''; -$moreheadjs=''; +$moreheadcss = ''; +$moreheadjs = ''; //$morejs=array(); -$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; -$moreheadjs.=''."\n"; +$moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); // Add sections to manage -$rowspan=0; -$sectionauto=array(); -if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) +$rowspan = 0; +$sectionauto = array(); +if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } - if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } - if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } - if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } - if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } - if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } - if (! empty($conf->supplier_proposal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBySupplierProposals")); } - if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } - if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } - if (! empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); } - if (! empty($conf->projet->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); } - if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } - if (! empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } - if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } - if (! empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); } - $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } + if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } + if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } + if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } + if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } + if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } + if (!empty($conf->supplier_proposal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBySupplierProposals")); } + if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } + if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } + if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); } + if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); } + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } + if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } + if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } + if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); } + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); } $head = ecm_prepare_dasboard_head(''); @@ -358,7 +358,7 @@ if ($action == 'delete' && empty($conf->use_javascript_ajax)) print '
    '; // Toolbar -$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); +$url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&module='.$module : '').($section ? '&section='.$section : ''))); print ''; print ''; print ''; @@ -391,28 +391,28 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act print ' '.$langs->trans("ECMSections"); print ''; - $showonrightsize=''; + $showonrightsize = ''; // Auto section if (count($sectionauto)) { - $htmltooltip=$langs->trans("ECMAreaDesc2"); + $htmltooltip = $langs->trans("ECMAreaDesc2"); - $sectionauto=dol_sort_array($sectionauto, 'label', 'ASC', true, false); + $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false); print ''; print ''; print '
      '; - $nbofentries=0; - $oldvallevel=0; + $nbofentries = 0; + $oldvallevel = 0; foreach ($sectionauto as $key => $val) { - if (empty($val['test'])) continue; // If condition to show is ok + if (empty($val['test'])) continue; // If condition to show is ok - $var=false; + $var = false; print ''; @@ -455,8 +455,8 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act // Start right panel -$mode='noajax'; -$url=DOL_URL_ROOT.'/ecm/index_auto.php'; +$mode = 'noajax'; +$url = DOL_URL_ROOT.'/ecm/index_auto.php'; include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; @@ -470,7 +470,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { +if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php'; } diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index c5c799d82c3..1b90ae77411 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -30,10 +30,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ecm', ''); // Load permissions @@ -42,13 +42,13 @@ $user->getrights('ecm'); // Get parameters $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); -$section=GETPOST('section'); -if (! $section) $section=0; +$section = GETPOST('section'); +if (!$section) $section = 0; $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module='ecm'; +if (empty($module)) $module = 'ecm'; $upload_dir = $conf->ecm->dir_output.'/'.$section; @@ -59,14 +59,14 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="label"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "label"; $ecmdir = new EcmDirectory($db); -if (! empty($section)) +if (!empty($section)) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; @@ -92,22 +92,22 @@ if (! empty($section)) llxHeader(); -$form=new Form($db); +$form = new Form($db); $ecmdirstatic = new EcmDirectory($db); $userstatic = new User($db); // Ajout rubriques automatiques -$rowspan=0; -$sectionauto=array(); -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } -if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } -if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } -if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } -if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } -if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } -if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } -if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +$rowspan = 0; +$sectionauto = array(); +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } +if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } +if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } +if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } +if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } +if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } //*********************** @@ -152,13 +152,13 @@ print ''; print ""; print ''; -$buthtml=''; -$butshown=0; -foreach($sectionauto as $sectioncur) +$buthtml = ''; +$butshown = 0; +foreach ($sectionauto as $sectioncur) { - if (! $sectioncur['test']) continue; + if (!$sectioncur['test']) continue; //if ($butshown % 2 == 0) - print ''; + print ''; print "'; print ' '; -print ''; +print ''; print "
      '.$langs->trans("ECMSearchByEntity").'
      ".$sectioncur['label'].': 
      "; //print $langs->trans("ECMSectionAutoDesc"); @@ -182,13 +182,13 @@ print ""; print ''; // Right area -$relativepath=$ecmdir->getRelativePath(); +$relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; -$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); +$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); -$formfile=new FormFile($db); -$param='&section='.$section; -$textifempty=($section?$langs->trans("NoFileFound"):$langs->trans("ECMSelectASection")); +$formfile = new FormFile($db); +$param = '&section='.$section; +$textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection")); $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty); // print ''; diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index 3f8b889aaff..4dd9cd63cb2 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -19,7 +19,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template enablefiletreeajax.tpl.php can't be called as URL"; exit; @@ -33,10 +33,10 @@ if (empty($conf) || ! is_object($conf)) '."\n"; @@ -409,7 +409,7 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl } print ''."\n"; - print ''."\n"; print ''."\n"; @@ -431,7 +431,7 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl */ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0) { - global $conf,$langs; + global $conf, $langs; $langs->load("main"); $langs->load("other"); @@ -440,15 +440,15 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print '
      '."\n"; print ''."\n"; - if (! $nonext || ($nonext == '2')) + if (!$nonext || ($nonext == '2')) { print '
      '; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"].'&ignoreerrors=1':'').'

      '; + print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '').'

      '; } - print '"'; + print '"'; if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"'; print '>
      '; if ($withpleasewait) print ''; @@ -466,7 +466,7 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print "\n"; print "'; $resql = $db->query($sql); } - foreach($listoftables as $table) + foreach ($listoftables as $table) { // do not convert llx_const if mysql encrypt/decrypt is used if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue; print ''; print $table; - $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; + $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; print ''; if ($force_utf8_on_tables == 'confirmed') { $resql = $db->query($sql); - print ' - Done ('.($resql?'OK':'KO').')'; + print ' - Done ('.($resql ? 'OK' : 'KO').')'; } else print ' - Disabled'; print ''; @@ -1387,7 +1387,7 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) // Enable foreign key checking if ($force_utf8_on_tables == 'confirmed') { - $sql='SET FOREIGN_KEY_CHECKS=1'; + $sql = 'SET FOREIGN_KEY_CHECKS=1'; print ''; $resql = $db->query($sql); } @@ -1429,7 +1429,7 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { echo 'Repair llx_commande_fournisseur_dispatch.fk_commandefourndet'; echo 'Repair in progress. This may take a while.'; - $sql_dispatch = 'SELECT * FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch WHERE COALESCE(fk_commandefourndet, 0) = 0'; + $sql_dispatch = 'SELECT * FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE COALESCE(fk_commandefourndet, 0) = 0'; $db->begin(); $resql_dispatch = $db->query($sql_dispatch); $n_processed_rows = 0; @@ -1440,9 +1440,9 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { exit; } while ($obj_dispatch = $db->fetch_object($resql_dispatch)) { - $sql_line = 'SELECT line.rowid, line.qty FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet AS line' - . ' WHERE line.fk_commande = ' . $obj_dispatch->fk_commande - . ' AND line.fk_product = ' . $obj_dispatch->fk_product; + $sql_line = 'SELECT line.rowid, line.qty FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet AS line' + . ' WHERE line.fk_commande = '.$obj_dispatch->fk_commande + . ' AND line.fk_product = '.$obj_dispatch->fk_product; $resql_line = $db->query($sql_line); // s’il y a plusieurs lignes avec le même produit sur cette commande fournisseur, @@ -1452,7 +1452,7 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $remaining_qty = $obj_dispatch->qty; $first_iteration = true; if (!$resql_line) { - echo 'Unable to find a matching supplier order line for dispatch #' . $obj_dispatch->rowid . ''; + echo 'Unable to find a matching supplier order line for dispatch #'.$obj_dispatch->rowid.''; $errors[] = $sql_line; $n_processed_rows++; continue; @@ -1465,9 +1465,9 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { } $qty_for_line = min($remaining_qty, $obj_line->qty); if ($first_iteration) { - $sql_attach = 'UPDATE ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch' - . ' SET fk_commandefourndet = ' . $obj_line->rowid . ', qty = ' . $qty_for_line - . ' WHERE rowid = ' . $obj_dispatch->rowid; + $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch' + . ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line + . ' WHERE rowid = '.$obj_dispatch->rowid; $first_iteration = false; } else { $sql_attach_values = array( @@ -1477,19 +1477,19 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $qty_for_line, $obj_dispatch->fk_entrepot, $obj_dispatch->fk_user, - $obj_dispatch->datec ? '"' . $db->escape($obj_dispatch->datec) . '"' : 'NULL', - $obj_dispatch->comment ? '"' . $db->escape($obj_dispatch->comment) . '"' : 'NULL', + $obj_dispatch->datec ? '"'.$db->escape($obj_dispatch->datec).'"' : 'NULL', + $obj_dispatch->comment ? '"'.$db->escape($obj_dispatch->comment).'"' : 'NULL', $obj_dispatch->status ?: 'NULL', - $obj_dispatch->tms ? '"' . $db->escape($obj_dispatch->tms) . '"': 'NULL', + $obj_dispatch->tms ? '"'.$db->escape($obj_dispatch->tms).'"' : 'NULL', $obj_dispatch->batch ?: 'NULL', - $obj_dispatch->eatby ? '"' . $db->escape($obj_dispatch->eatby) . '"': 'NULL', - $obj_dispatch->sellby ? '"' . $db->escape($obj_dispatch->sellby) . '"': 'NULL' + $obj_dispatch->eatby ? '"'.$db->escape($obj_dispatch->eatby).'"' : 'NULL', + $obj_dispatch->sellby ? '"'.$db->escape($obj_dispatch->sellby).'"' : 'NULL' ); $sql_attach_values = join(', ', $sql_attach_values); - $sql_attach = 'INSERT INTO ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch' + $sql_attach = 'INSERT INTO '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch' . ' (fk_commande, fk_product, fk_commandefourndet, qty, fk_entrepot, fk_user, datec, comment, status, tms, batch, eatby, sellby)' - . ' VALUES (' . $sql_attach_values . ')'; + . ' VALUES ('.$sql_attach_values.')'; } if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') @@ -1498,7 +1498,7 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { } else { - $resql_attach = true; // Force success in test mode + $resql_attach = true; // Force success in test mode } if ($resql_attach) { @@ -1513,17 +1513,17 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { // report progress every 256th row if (!($n_processed_rows & 0xff)) { - echo 'Processed ' . $n_processed_rows . ' rows with ' . count($errors) . ' errors…' . "\n"; + echo 'Processed '.$n_processed_rows.' rows with '.count($errors).' errors…'."\n"; flush(); ob_flush(); } } } else { - echo 'Unable to find any dispatch without an fk_commandefourndet.' . "\n"; - echo $sql_dispatch . "\n"; + echo 'Unable to find any dispatch without an fk_commandefourndet.'."\n"; + echo $sql_dispatch."\n"; } - echo 'Fixed ' . $n_processed_rows . ' rows with ' . count($errors) . ' errors…' . "\n"; - echo 'DONE.' . "\n"; + echo 'Fixed '.$n_processed_rows.' rows with '.count($errors).' errors…'."\n"; + echo 'DONE.'."\n"; if (count($errors)) { $db->rollback(); @@ -1534,7 +1534,7 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $db->close(); echo '

      SQL queries with errors:

      '; - echo '' . join('', $errors) . ''; + echo ''.join('', $errors).''; } print ''; @@ -1548,7 +1548,7 @@ if (empty($actiondone)) if ($oneoptionset) { - print '
      '; + print ''; } @@ -1565,4 +1565,4 @@ pFooter(1, $setuplang); if ($db->connected) $db->close(); // Return code if ran from command line -if (! $ok && isset($argv[1])) exit(1); +if (!$ok && isset($argv[1])) exit(1); diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 62d984bf1f3..9d81bca42ce 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -26,37 +26,37 @@ * \brief Build conf file on disk */ -define('DONOTLOADCONF', 1); // To avoid loading conf by file inc.php +define('DONOTLOADCONF', 1); // To avoid loading conf by file inc.php include 'inc.php'; global $langs; -$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):(empty($argv[1])?'':$argv[1]); -$setuplang=GETPOST('selectlang', 'aZ09', 3)?GETPOST('selectlang', 'aZ09', 3):(empty($argv[2])?'auto':$argv[2]); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]); +$setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[2]) ? 'auto' : $argv[2]); $langs->setDefaultLang($setuplang); $langs->loadLangs(array("admin", "install", "errors")); // Dolibarr pages directory -$main_dir = GETPOST('main_dir')?GETPOST('main_dir'):(empty($argv[3])?'':$argv[3]); +$main_dir = GETPOST('main_dir') ?GETPOST('main_dir') : (empty($argv[3]) ? '' : $argv[3]); // Directory for generated documents (invoices, orders, ecm, etc...) -$main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : (empty($argv[4])? ($main_dir . '/documents') :$argv[4]); +$main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : (empty($argv[4]) ? ($main_dir.'/documents') : $argv[4]); // Dolibarr root URL -$main_url = GETPOST('main_url')?GETPOST('main_url'):(empty($argv[5])?'':$argv[5]); +$main_url = GETPOST('main_url') ?GETPOST('main_url') : (empty($argv[5]) ? '' : $argv[5]); // Database login information -$userroot=GETPOST('db_user_root', 'alpha')?GETPOST('db_user_root', 'alpha'):(empty($argv[6])?'':$argv[6]); -$passroot=GETPOST('db_pass_root', 'none')?GETPOST('db_pass_root', 'none'):(empty($argv[7])?'':$argv[7]); +$userroot = GETPOST('db_user_root', 'alpha') ?GETPOST('db_user_root', 'alpha') : (empty($argv[6]) ? '' : $argv[6]); +$passroot = GETPOST('db_pass_root', 'none') ?GETPOST('db_pass_root', 'none') : (empty($argv[7]) ? '' : $argv[7]); // Database server -$db_type=GETPOST('db_type', 'aZ09')?GETPOST('db_type', 'aZ09'):(empty($argv[8])?'':$argv[8]); -$db_host=GETPOST('db_host', 'alpha')?GETPOST('db_host', 'alpha'):(empty($argv[9])?'':$argv[9]); -$db_name=GETPOST('db_name', 'aZ09')?GETPOST('db_name', 'aZ09'):(empty($argv[10])?'':$argv[10]); -$db_user=GETPOST('db_user', 'alpha')?GETPOST('db_user', 'alpha'):(empty($argv[11])?'':$argv[11]); -$db_pass=GETPOST('db_pass', 'none')?GETPOST('db_pass', 'none'):(empty($argv[12])?'':$argv[12]); -$db_port=GETPOST('db_port', 'int')?GETPOST('db_port', 'int'):(empty($argv[13])?'':$argv[13]); -$db_prefix=GETPOST('db_prefix', 'aZ09')?GETPOST('db_prefix', 'aZ09'):(empty($argv[14])?'':$argv[14]); -$db_create_database = GETPOST('db_create_database', 'none')?GETPOST('db_create_database', 'none'):(empty($argv[15])?'':$argv[15]); -$db_create_user = GETPOST('db_create_user', 'none')?GETPOST('db_create_user', 'none'):(empty($argv[16])?'':$argv[16]); +$db_type = GETPOST('db_type', 'aZ09') ?GETPOST('db_type', 'aZ09') : (empty($argv[8]) ? '' : $argv[8]); +$db_host = GETPOST('db_host', 'alpha') ?GETPOST('db_host', 'alpha') : (empty($argv[9]) ? '' : $argv[9]); +$db_name = GETPOST('db_name', 'aZ09') ?GETPOST('db_name', 'aZ09') : (empty($argv[10]) ? '' : $argv[10]); +$db_user = GETPOST('db_user', 'alpha') ?GETPOST('db_user', 'alpha') : (empty($argv[11]) ? '' : $argv[11]); +$db_pass = GETPOST('db_pass', 'none') ?GETPOST('db_pass', 'none') : (empty($argv[12]) ? '' : $argv[12]); +$db_port = GETPOST('db_port', 'int') ?GETPOST('db_port', 'int') : (empty($argv[13]) ? '' : $argv[13]); +$db_prefix = GETPOST('db_prefix', 'aZ09') ?GETPOST('db_prefix', 'aZ09') : (empty($argv[14]) ? '' : $argv[14]); +$db_create_database = GETPOST('db_create_database', 'none') ?GETPOST('db_create_database', 'none') : (empty($argv[15]) ? '' : $argv[15]); +$db_create_user = GETPOST('db_create_user', 'none') ?GETPOST('db_create_user', 'none') : (empty($argv[16]) ? '' : $argv[16]); // Force https $main_force_https = ((GETPOST("main_force_https", 'alpha') && (GETPOST("main_force_https", 'alpha') == "on" || GETPOST("main_force_https", 'alpha') == 1)) ? '1' : '0'); // Use alternative directory @@ -64,16 +64,16 @@ $main_use_alt_dir = ((GETPOST("main_use_alt_dir", 'alpha') == '' || (GETPOST("ma // Alternative root directory name $main_alt_dir_name = ((GETPOST("main_alt_dir_name", 'alpha') && GETPOST("main_alt_dir_name", 'alpha') != '') ? GETPOST("main_alt_dir_name", 'alpha') : 'custom'); -session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters) +session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters) // Save a flag to tell to restore input value if we go back -$_SESSION['dol_save_pass']=$db_pass; +$_SESSION['dol_save_pass'] = $db_pass; //$_SESSION['dol_save_passroot']=$passroot; // Now we load forced values from install.forced.php file. -$useforcedwizard=false; -$forcedfile="./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; +$useforcedwizard = false; +$forcedfile = "./install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -142,7 +142,7 @@ dolibarr_install_syslog("--- step1: entering step1.php page"); pHeader($langs->trans("ConfigurationFile"), "step2"); // Test if we can run a first install process -if (! is_writable($conffile)) +if (!is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); pFooter(1, $setuplang, 'jscheckparam'); @@ -157,9 +157,9 @@ if (empty($db_type)) print '
      '.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseType")).'
      '; $error++; } else { - $is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3' ); + $is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3'); } -if (empty($db_host) && ! $is_sqlite) +if (empty($db_host) && !$is_sqlite) { print '
      '.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Server")).'
      '; $error++; @@ -169,17 +169,17 @@ if (empty($db_name)) print '
      '.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseName")).'
      '; $error++; } -if (empty($db_user) && ! $is_sqlite) +if (empty($db_user) && !$is_sqlite) { print '
      '.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")).'
      '; $error++; } -if (! empty($db_port) && ! is_numeric($db_port)) +if (!empty($db_port) && !is_numeric($db_port)) { print '
      '.$langs->trans("ErrorBadValueForParameter", $db_port, $langs->transnoentities("Port")).'
      '; $error++; } -if (! empty($db_prefix) && ! preg_match('/^[a-z0-9]+_$/i', $db_prefix)) +if (!empty($db_prefix) && !preg_match('/^[a-z0-9]+_$/i', $db_prefix)) { print '
      '.$langs->trans("ErrorBadValueForParameter", $db_prefix, $langs->transnoentities("DatabasePrefix")).'
      '; $error++; @@ -187,20 +187,20 @@ if (! empty($db_prefix) && ! preg_match('/^[a-z0-9]+_$/i', $db_prefix)) // Remove last / into dans main_dir -if (substr($main_dir, dol_strlen($main_dir) -1) == "/") +if (substr($main_dir, dol_strlen($main_dir) - 1) == "/") { - $main_dir = substr($main_dir, 0, dol_strlen($main_dir)-1); + $main_dir = substr($main_dir, 0, dol_strlen($main_dir) - 1); } // Remove last / into dans main_url -if (! empty($main_url) && substr($main_url, dol_strlen($main_url) -1) == "/") +if (!empty($main_url) && substr($main_url, dol_strlen($main_url) - 1) == "/") { - $main_url = substr($main_url, 0, dol_strlen($main_url)-1); + $main_url = substr($main_url, 0, dol_strlen($main_url) - 1); } // Test database connection -if (! $error) { - $result=@include_once $main_dir."/core/db/".$db_type.'.class.php'; +if (!$error) { + $result = @include_once $main_dir."/core/db/".$db_type.'.class.php'; if ($result) { // If we require database or user creation we need to connect as root, so we need root login credentials @@ -221,39 +221,39 @@ if (! $error) { // If we need root access if (!$error && (!empty($db_create_database) || !empty($db_create_user))) { - $databasefortest=$db_name; + $databasefortest = $db_name; if (!empty($db_create_database)) { if ($db_type == 'mysql' || $db_type == 'mysqli') { - $databasefortest='mysql'; + $databasefortest = 'mysql'; } elseif ($db_type == 'pgsql') { - $databasefortest='postgres'; + $databasefortest = 'postgres'; } else { - $databasefortest='master'; + $databasefortest = 'master'; } } //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"]; - $db=getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port); + $db = getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port); - dol_syslog("databasefortest=" . $databasefortest . " connected=" . $db->connected . " database_selected=" . $db->database_selected, LOG_DEBUG); + dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG); //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected; if (empty($db_create_database) && $db->connected && !$db->database_selected) { print '
      '.$langs->trans("ErrorConnectedButDatabaseNotFound", $db_name).'
      '; print '
      '; - if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'

      '; + if (!$db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'

      '; print $langs->trans("ErrorGoBackAndCorrectParameters"); $error++; - } elseif ($db->error && ! (! empty($db_create_database) && $db->connected)) { + } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) { // Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched. if ($db->error == "No such file or directory") print '
      '.$langs->trans("ErrorToConnectToMysqlCheckInstance").'
      '; else print '
      '.$db->error.'
      '; - if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'

      '; + if (!$db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'

      '; //print ''; print $langs->trans("ErrorGoBackAndCorrectParameters"); //print ''; @@ -262,12 +262,12 @@ if (! $error) { } // If we need simple access if (!$error && (empty($db_create_database) && empty($db_create_user))) { - $db=getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port); + $db = getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port); if ($db->error) { print '
      '.$db->error.'
      '; - if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'

      '; + if (!$db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'

      '; //print ''; print $langs->trans("ErrorGoBackAndCorrectParameters"); //print ''; @@ -289,15 +289,15 @@ if (! $error) { else { if (isset($db)) print $db->lasterror(); - if (isset($db) && ! $db->connected) print '
      '.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'

      '; + if (isset($db) && !$db->connected) print '
      '.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'

      '; print $langs->trans("ErrorGoBackAndCorrectParameters"); $error++; } -if (! $error && $db->connected) +if (!$error && $db->connected) { - if (! empty($db_create_database)) { - $result=$db->select_db($db_name); + if (!empty($db_create_database)) { + $result = $db->select_db($db_name); if ($result) { print '
      '.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'
      '; @@ -309,19 +309,19 @@ if (! $error && $db->connected) } // Define $defaultCharacterSet and $defaultDBSortingCollation -if (! $error && $db->connected) +if (!$error && $db->connected) { if (!empty($db_create_database)) // If we create database, we force default value { // Default values come from the database handler - $defaultCharacterSet=$db->forcecharset; - $defaultDBSortingCollation=$db->forcecollate; + $defaultCharacterSet = $db->forcecharset; + $defaultDBSortingCollation = $db->forcecollate; } else // If already created, we take current value { - $defaultCharacterSet=$db->getDefaultCharacterSetDatabase(); - $defaultDBSortingCollation=$db->getDefaultCollationDatabase(); + $defaultCharacterSet = $db->getDefaultCharacterSetDatabase(); + $defaultDBSortingCollation = $db->getDefaultCollationDatabase(); } // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29) @@ -334,22 +334,22 @@ if (! $error && $db->connected) print ''; print ''; - $db_character_set=$defaultCharacterSet; - $db_collation=$defaultDBSortingCollation; - dolibarr_install_syslog("step1: db_character_set=" . $db_character_set . " db_collation=" . $db_collation); + $db_character_set = $defaultCharacterSet; + $db_collation = $defaultDBSortingCollation; + dolibarr_install_syslog("step1: db_character_set=".$db_character_set." db_collation=".$db_collation); } // Create config file -if (! $error && $db->connected && $action == "set") +if (!$error && $db->connected && $action == "set") { umask(0); if (is_array($_POST)) { - foreach($_POST as $key => $value) + foreach ($_POST as $key => $value) { - if (! preg_match('/^db_pass/i', $key)) { - dolibarr_install_syslog("step1: choice for " . $key . " = " . $value); + if (!preg_match('/^db_pass/i', $key)) { + dolibarr_install_syslog("step1: choice for ".$key." = ".$value); } } } @@ -359,11 +359,11 @@ if (! $error && $db->connected && $action == "set") print ''; // Check parameter main_dir - if (! $error) + if (!$error) { - if (! is_dir($main_dir)) + if (!is_dir($main_dir)) { - dolibarr_install_syslog("step1: directory '" . $main_dir . "' is unavailable or can't be accessed"); + dolibarr_install_syslog("step1: directory '".$main_dir."' is unavailable or can't be accessed"); print "'; @@ -509,10 +509,10 @@ if (! $error && $db->connected && $action == "set") } // Table prefix - $main_db_prefix = (! empty($db_prefix) ? $db_prefix : 'llx_'); + $main_db_prefix = (!empty($db_prefix) ? $db_prefix : 'llx_'); // Write conf file on disk - if (! $error) + if (!$error) { // Save old conf file on disk if (file_exists("$conffile")) @@ -523,11 +523,11 @@ if (! $error && $db->connected && $action == "set") @dol_copy($conffile, $conffile.'.old', '0400'); } - $error+=write_conf_file($conffile); + $error += write_conf_file($conffile); } // Create database and admin user database - if (! $error) + if (!$error) { // We reload configuration file conf($dolibarr_main_document_root); @@ -539,26 +539,26 @@ if (! $error && $db->connected && $action == "set") // Create database user if requested if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) { - dolibarr_install_syslog("step1: create database user: " . $dolibarr_main_db_user); + dolibarr_install_syslog("step1: create database user: ".$dolibarr_main_db_user); //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port; - $databasefortest=$conf->db->name; + $databasefortest = $conf->db->name; if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { - $databasefortest='mysql'; + $databasefortest = 'mysql'; } elseif ($conf->db->type == 'pgsql') { - $databasefortest='postgres'; + $databasefortest = 'postgres'; } elseif ($conf->db->type == 'mssql') { - $databasefortest='master'; + $databasefortest = 'master'; } // Check database connection - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, $conf->db->port); if ($db->error) { @@ -643,13 +643,13 @@ if (! $error && $db->connected && $action == "set") // If database creation was asked, we create it if (!$error && (isset($db_create_database) && ($db_create_database == "1" || $db_create_database == "on"))) { - dolibarr_install_syslog("step1: create database: " . $dolibarr_main_db_name . " " . $dolibarr_main_db_character_set . " " . $dolibarr_main_db_collation . " " . $dolibarr_main_db_user); - $newdb=getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, '', $conf->db->port); + dolibarr_install_syslog("step1: create database: ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user); + $newdb = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, '', $conf->db->port); //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit; if ($newdb->connected) { - $result=$newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user); + $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user); if ($result) { @@ -660,9 +660,9 @@ if (! $error && $db->connected && $action == "set") print ''; $newdb->select_db($dolibarr_main_db_name); - $check1=$newdb->getDefaultCharacterSetDatabase(); - $check2=$newdb->getDefaultCollationDatabase(); - dolibarr_install_syslog('step1: new database is using charset=' . $check1 . ' collation=' . $check2); + $check1 = $newdb->getDefaultCharacterSetDatabase(); + $check2 = $newdb->getDefaultCollationDatabase(); + dolibarr_install_syslog('step1: new database is using charset='.$check1.' collation='.$check2); // If values differs, we save conf file again //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING); @@ -678,7 +678,7 @@ if (! $error && $db->connected && $action == "set") print '
      '; print ''; - dolibarr_install_syslog('step1: failed to create database ' . $dolibarr_main_db_name . ' ' . $newdb->lasterrno() . ' ' . $newdb->lasterror(), LOG_ERR); + dolibarr_install_syslog('step1: failed to create database '.$dolibarr_main_db_name.' '.$newdb->lasterrno().' '.$newdb->lasterror(), LOG_ERR); $error++; } $newdb->close(); @@ -705,16 +705,16 @@ if (! $error && $db->connected && $action == "set") // We test access with dolibarr database user (not admin) - if (! $error) + if (!$error) { - dolibarr_install_syslog("step1: connection type=" . $conf->db->type . " on host=" . $conf->db->host . " port=" . $conf->db->port . " user=" . $conf->db->user . " name=" . $conf->db->name); + dolibarr_install_syslog("step1: connection type=".$conf->db->type." on host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name); //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); if ($db->connected) { - dolibarr_install_syslog("step1: connection to server by user " . $conf->db->user . " ok"); + dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." ok"); print ""; print ''; print '\n"; print ''; print ''; print ''; print ''; // Number @@ -305,7 +305,7 @@ if ($action == 'create') print ' @@ -78,7 +78,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) if (count($linkedObjectBlock) > 1) { ?> - + diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index 8e45cd9c015..1035d17d5f9 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -38,24 +38,24 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; $langs->load("companies"); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); +$search_agenda_label = GETPOST('search_agenda_label'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -63,8 +63,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC,DESC'; +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; $object = new DolResource($db); $object->fetch($id, $ref); @@ -75,7 +75,7 @@ $extrafields = new ExtraFields($db); $hookmanager->initHooks(array('agendaresource')); // Security check -if( ! $user->rights->resource->read) +if (!$user->rights->resource->read) { accessforbidden(); } @@ -85,14 +85,14 @@ if( ! $user->rights->resource->read) * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -101,8 +101,8 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } } @@ -123,25 +123,25 @@ if ($object->id > 0) $langs->load("companies"); $picto = 'resource'; - $title=$langs->trans("Agenda"); - if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref." - ".$title; + $title = $langs->trans("Agenda"); + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref." - ".$title; llxHeader('', $title); - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $type = $langs->trans('ResourceSingular'); $head = resource_prepare_head($object); - $titre=$langs->trans("ResourceSingular"); + $titre = $langs->trans("ResourceSingular"); dol_fiche_head($head, 'agenda', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; - $morehtmlref.='
      '; + $morehtmlref = '
      '; + $morehtmlref .= '
      '; $shownav = 1; - if ($user->socid && ! in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -152,17 +152,17 @@ if ($object->id > 0) dol_fiche_end(); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param='&id='.$object->id.'&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + $param = '&id='.$object->id.'&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); // List of all actions - $filters=array(); - $filters['search_agenda_label']=$search_agenda_label; + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php index f57b810394a..cbc94c2e843 100644 --- a/htdocs/resource/contact.php +++ b/htdocs/resource/contact.php @@ -39,7 +39,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'resource', $id, 'resource'); $object = new DolResource($db); @@ -79,7 +79,7 @@ if ($action == 'addcontact' && $user->rights->resource->write) // Toggle the status of a contact elseif ($action == 'swapstatut' && $user->rights->resource->write) { - $result=$object->swapContactStatus(GETPOST('ligne', 'int')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } // Erase a contact @@ -104,14 +104,14 @@ elseif ($action == 'deletecontact' && $user->rights->resource->write) $form = new Form($db); $formcompany = new FormCompany($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); llxHeader('', $langs->trans("Resource")); // Mode vue et edition -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $soc = new Societe($db); $soc->fetch($object->socid); @@ -121,11 +121,11 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'contact', $langs->trans("ResourceSingular"), -1, 'resource'); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; - $morehtmlref.='
      '; + $morehtmlref = '
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -141,7 +141,7 @@ if ($id > 0 || ! empty($ref)) // Resource type print ''; - print ''; + print ''; print ''; @@ -154,10 +154,10 @@ if ($id > 0 || ! empty($ref)) print '
      '; - if (! empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1; - if (! empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1; + if (!empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser = 1; + if (!empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty = 1; - $permission=1; + $permission = 1; // Contacts lines include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; } diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index 174b1503dbe..5f053be4321 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -44,7 +44,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'resource', $id, 'resource'); @@ -56,22 +56,22 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new DolResource($db); $object->fetch($id, $ref); $upload_dir = $conf->resource->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='resource'; +$modulepart = 'resource'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -86,25 +86,25 @@ if ($object->id > 0) { $object->fetch_thirdparty(); - $head=resource_prepare_head($object); + $head = resource_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("ResourceSingular"), -1, 'resource'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; - $morehtmlref.='
      '; + $morehtmlref = '
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -117,7 +117,7 @@ if ($object->id > 0) // Resource type print ''; - print ''; + print ''; print ''; @@ -134,7 +134,7 @@ if ($object->id > 0) $modulepart = 'dolresource'; $permission = $user->rights->resource->write; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 54cc8963b75..07c43251d3d 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -58,11 +58,11 @@ $search_type = GETPOST("search_type", 'alpha'); $filter = array(); if ($search_ref != '') { - $param.='&search_ref='.urlencode($search_ref); + $param .= '&search_ref='.urlencode($search_ref); $filter['t.ref'] = $search_ref; } if ($search_type != '') { - $param.='&search_type='.urlencode($search_type); + $param .= '&search_type='.urlencode($search_type); $filter['ty.label'] = $search_type; } @@ -83,7 +83,7 @@ foreach ($search_array_options as $key => $val) $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search); } } -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); $hookmanager->initHooks(array('resourcelist')); diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php index 322088ef317..1162909114e 100644 --- a/htdocs/resource/note.php +++ b/htdocs/resource/note.php @@ -34,23 +34,23 @@ $langs->loadLangs(array('companies', 'interventions')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'resource', $id, 'resource'); $object = new DolResource($db); $object->fetch($id, $ref); -$permissionnote=$user->rights->resource->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->resource->write; // Used by the include of actions_setnotes.inc.php /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* @@ -61,16 +61,16 @@ llxHeader(); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $head = resource_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans('ResourceSingular'), -1, 'resource'); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; - $morehtmlref.='
      '; + $morehtmlref = '
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -83,7 +83,7 @@ if ($id > 0 || ! empty($ref)) // Resource type print ''; - print ''; + print ''; print ''; @@ -93,8 +93,8 @@ if ($id > 0 || ! empty($ref)) print ''; - $permission=$user->rights->resource->write; - $cssclass='titlefield'; + $permission = $user->rights->resource->write; + $cssclass = 'titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/salaries/admin/salaries.php b/htdocs/salaries/admin/salaries.php index 6ab5f5d13b0..29e3c325ee0 100644 --- a/htdocs/salaries/admin/salaries.php +++ b/htdocs/salaries/admin/salaries.php @@ -27,7 +27,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'salaries')); @@ -39,7 +39,7 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); // Other parameters SALARIES_* -$list = array ( +$list = array( 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); @@ -59,7 +59,7 @@ if ($action == 'update') } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -76,9 +76,9 @@ if ($action == 'update') llxHeader('', $langs->trans('SalariesSetup')); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup'); $head = salaries_admin_prepare_head(); @@ -111,7 +111,7 @@ foreach ($list as $key) // Value print ''; // Year print ''; @@ -221,11 +221,11 @@ print ''; print ''; print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while ($year && $oldyear > $year+1) + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; @@ -244,7 +244,7 @@ foreach ($data as $val) print ''; print ''; print ''; - $oldyear=$year; + $oldyear = $year; } print '
      "; print $langs->trans("ErrorDirDoesNotExists", $main_dir).'
      '; @@ -376,22 +376,22 @@ if (! $error && $db->connected && $action == "set") } } - if (! $error) + if (!$error) { - dolibarr_install_syslog("step1: directory '" . $main_dir . "' exists"); + dolibarr_install_syslog("step1: directory '".$main_dir."' exists"); } // Create subdirectory main_data_dir - if (! $error) + if (!$error) { // Create directory for documents - if (! is_dir($main_data_dir)) + if (!is_dir($main_data_dir)) { dol_mkdir($main_data_dir); } - if (! is_dir($main_data_dir)) + if (!is_dir($main_data_dir)) { print "
      ".$langs->trans("ErrorDirDoesNotExists", $main_data_dir); print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite"); @@ -404,11 +404,11 @@ if (! $error && $db->connected && $action == "set") else { // Create .htaccess file in document directory - $pathhtaccess=$main_data_dir.'/.htaccess'; - if (! file_exists($pathhtaccess)) + $pathhtaccess = $main_data_dir.'/.htaccess'; + if (!file_exists($pathhtaccess)) { - dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '" . $main_data_dir . "'"); - $handlehtaccess=@fopen($pathhtaccess, 'w'); + dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '".$main_data_dir."'"); + $handlehtaccess = @fopen($pathhtaccess, 'w'); if ($handlehtaccess) { fwrite($handlehtaccess, 'Order allow,deny'."\n"); @@ -420,7 +420,7 @@ if (! $error && $db->connected && $action == "set") } // Documents are stored above the web pages root to prevent being downloaded without authentification - $dir=array(); + $dir = array(); $dir[] = $main_data_dir."/mycompany"; $dir[] = $main_data_dir."/medias"; $dir[] = $main_data_dir."/users"; @@ -431,12 +431,12 @@ if (! $error && $db->connected && $action == "set") $dir[] = $main_data_dir."/doctemplates"; // Loop on each directory of dir [] to create them if they do not exist - $num=count($dir); + $num = count($dir); for ($i = 0; $i < $num; $i++) { if (is_dir($dir[$i])) { - dolibarr_install_syslog("step1: directory '" . $dir[$i] . "' exists"); + dolibarr_install_syslog("step1: directory '".$dir[$i]."' exists"); } else { @@ -451,7 +451,7 @@ if (! $error && $db->connected && $action == "set") } else { - dolibarr_install_syslog("step1: directory '" . $dir[$i] . "' created"); + dolibarr_install_syslog("step1: directory '".$dir[$i]."' created"); } } } @@ -459,8 +459,8 @@ if (! $error && $db->connected && $action == "set") require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Copy directory medias - $srcroot=$main_dir.'/install/medias'; - $destroot=$main_data_dir.'/medias'; + $srcroot = $main_dir.'/install/medias'; + $destroot = $main_data_dir.'/medias'; dolCopyDir($srcroot, $destroot, 0, 0); if ($error) @@ -475,9 +475,9 @@ if (! $error && $db->connected && $action == "set") else { //ODT templates - $srcroot=$main_dir.'/install/doctemplates'; - $destroot=$main_data_dir.'/doctemplates'; - $docs=array( + $srcroot = $main_dir.'/install/doctemplates'; + $destroot = $main_data_dir.'/doctemplates'; + $docs = array( 'contracts' => 'contract', 'invoices' => 'invoice', 'orders' => 'order', @@ -491,14 +491,14 @@ if (! $error && $db->connected && $action == "set") 'usergroups' => 'usergroups', 'users' => 'user', ); - foreach($docs as $cursordir => $cursorfile) + foreach ($docs as $cursordir => $cursorfile) { - $src=$srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt'; - $dirodt=$destroot.'/'.$cursordir; - $dest=$dirodt.'/template_'.$cursorfile.'.odt'; + $src = $srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt'; + $dirodt = $destroot.'/'.$cursordir; + $dest = $dirodt.'/template_'.$cursorfile.'.odt'; dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); + $result = dol_copy($src, $dest, 0, 0); if ($result < 0) { print '

      '.$langs->trans('ErrorFailToCopyFile', $src, $dest).'
      Ok
      "; print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : "; print $dolibarr_main_db_host; @@ -725,7 +725,7 @@ if (! $error && $db->connected && $action == "set") // server access ok, basic access ok if ($db->database_selected) { - dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " ok"); + dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." ok"); print "
      "; print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : "; print $dolibarr_main_db_name; @@ -737,7 +737,7 @@ if (! $error && $db->connected && $action == "set") } else { - dolibarr_install_syslog("step1: connection to database " . $conf->db->name . " by user " . $conf->db->user . " failed", LOG_ERR); + dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." failed", LOG_ERR); print "
      "; print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : "; print $dolibarr_main_db_name; @@ -757,7 +757,7 @@ if (! $error && $db->connected && $action == "set") } else { - dolibarr_install_syslog("step1: connection to server by user " . $conf->db->user . " failed", LOG_ERR); + dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." failed", LOG_ERR); print "
      "; print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : "; print $dolibarr_main_db_host; @@ -798,13 +798,13 @@ function jsinfo() "; diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 7a4a3a92595..5b794b781bd 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -36,31 +36,31 @@ $ok = 0; // Cette page peut etre longue. On augmente le delai autorise. // Ne fonctionne que si on est pas en safe_mode. -$err=error_reporting(); -error_reporting(0); // Disable all errors +$err = error_reporting(); +error_reporting(0); // Disable all errors //error_reporting(E_ALL); -@set_time_limit(900); // Need 900 on some OS like Windows 7/64 +@set_time_limit(900); // Need 900 on some OS like Windows 7/64 error_reporting($err); -$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):(empty($argv[1])?'':$argv[1]); -$setuplang=GETPOST('selectlang', 'aZ09', 3)?GETPOST('selectlang', 'aZ09', 3):(empty($argv[2])?'auto':$argv[2]); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]); +$setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[2]) ? 'auto' : $argv[2]); $langs->setDefaultLang($setuplang); $langs->loadLangs(array("admin", "install")); -$choix=0; -if ($dolibarr_main_db_type == "mysqli") $choix=1; -if ($dolibarr_main_db_type == "pgsql") $choix=2; -if ($dolibarr_main_db_type == "mssql") $choix=3; -if ($dolibarr_main_db_type == "sqlite") $choix=4; -if ($dolibarr_main_db_type == "sqlite3") $choix=5; +$choix = 0; +if ($dolibarr_main_db_type == "mysqli") $choix = 1; +if ($dolibarr_main_db_type == "pgsql") $choix = 2; +if ($dolibarr_main_db_type == "mssql") $choix = 3; +if ($dolibarr_main_db_type == "sqlite") $choix = 4; +if ($dolibarr_main_db_type == "sqlite3") $choix = 5; //if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into step2.php page'); // Now we load forced values from install.forced.php file. -$useforcedwizard=false; -$forcedfile="./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; +$useforcedwizard = false; +$forcedfile = "./install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -78,7 +78,7 @@ dolibarr_install_syslog("- step2: entering step2.php page"); pHeader($langs->trans("CreateDatabaseObjects"), "step4"); // Test if we can run a first install process -if (! is_writable($conffile)) +if (!is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); pFooter(1, $setuplang, 'jscheckparam'); @@ -90,15 +90,15 @@ if ($action == "set") print '

      Database '.$langs->trans("Database").'

      '; print ''; - $error=0; + $error = 0; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); if ($db->connected) { print "'; - $ok = 1 ; + $ok = 1; } else { @@ -107,15 +107,15 @@ if ($action == "set") if ($ok) { - if($db->database_selected) + if ($db->database_selected) { - dolibarr_install_syslog("step2: successful connection to database: " . $conf->db->name); + dolibarr_install_syslog("step2: successful connection to database: ".$conf->db->name); } else { - dolibarr_install_syslog("step2: failed connection to database :" . $conf->db->name, LOG_ERR); + dolibarr_install_syslog("step2: failed connection to database :".$conf->db->name, LOG_ERR); print "'; - $ok = 0 ; + $ok = 0; } } @@ -123,8 +123,8 @@ if ($action == "set") // Affiche version if ($ok) { - $version=$db->getVersion(); - $versionarray=$db->getVersionArray(); + $version = $db->getVersion(); + $versionarray = $db->getVersionArray(); print ''; print ''; //print ''; @@ -134,18 +134,18 @@ if ($action == "set") //print ''; } - $requestnb=0; + $requestnb = 0; // To disable some code, so you can call step2 with url like // http://localhost/dolibarrnew/install/step2.php?action=set&createtables=0&createkeys=0&createfunctions=0&createdata=llx_20_c_departements - $createtables=isset($_GET['createtables'])?GETPOST('createtables'):1; - $createkeys=isset($_GET['createkeys'])?GETPOST('createkeys'):1; - $createfunctions=isset($_GET['createfunctions'])?GETPOST('createfunction'):1; - $createdata=isset($_GET['createdata'])?GETPOST('createdata'):1; + $createtables = isset($_GET['createtables']) ?GETPOST('createtables') : 1; + $createkeys = isset($_GET['createkeys']) ?GETPOST('createkeys') : 1; + $createfunctions = isset($_GET['createfunctions']) ?GETPOST('createfunction') : 1; + $createdata = isset($_GET['createdata']) ?GETPOST('createdata') : 1; // To say sql requests are escaped for mysql so we need to unescape them - $db->unescapeslashquot=true; + $db->unescapeslashquot = true; /************************************************************************************** @@ -160,18 +160,18 @@ if ($action == "set") $dir = "mysql/tables/"; $ok = 0; - $handle=opendir($dir); - dolibarr_install_syslog("step2: open tables directory " . $dir . " handle=" . $handle); + $handle = opendir($dir); + dolibarr_install_syslog("step2: open tables directory ".$dir." handle=".$handle); $tablefound = 0; - $tabledata=array(); + $tabledata = array(); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && ! preg_match('/\.key\.sql$/i', $file)) + if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file)) { $tablefound++; - $tabledata[]=$file; + $tabledata[] = $file; } } closedir($handle); @@ -179,7 +179,7 @@ if ($action == "set") // Sort list of sql files on alphabetical order (load order is important) sort($tabledata); - foreach($tabledata as $file) + foreach ($tabledata as $file) { $name = substr($file, 0, dol_strlen($file) - 4); $buffer = ''; @@ -191,36 +191,36 @@ if ($action == "set") $buf = fgets($fp, 4096); if (substr($buf, 0, 2) <> '--') { - $buf=preg_replace('/--(.+)*/', '', $buf); + $buf = preg_replace('/--(.+)*/', '', $buf); $buffer .= $buf; } } fclose($fp); - $buffer=trim($buffer); + $buffer = trim($buffer); if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb { - $buffer=preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer); + $buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer); } else { // Keyword ENGINE is MySQL-specific, so scrub it for // other database types (mssql, pgsql) - $buffer=preg_replace('/type=innodb/i', '', $buffer); - $buffer=preg_replace('/ENGINE=innodb/i', '', $buffer); + $buffer = preg_replace('/type=innodb/i', '', $buffer); + $buffer = preg_replace('/ENGINE=innodb/i', '', $buffer); } // Replace the prefix tables if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); + $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } //print ""; @@ -249,7 +249,7 @@ if ($action == "set") print ""; print ''; $error++; - dolibarr_install_syslog("step2: failed to open file " . $dir . $file, LOG_ERR); + dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR); } } @@ -265,7 +265,7 @@ if ($action == "set") else { print ''; - dolibarr_install_syslog("step2: failed to find files to create database in directory " . $dir, LOG_ERR); + dolibarr_install_syslog("step2: failed to find files to create database in directory ".$dir, LOG_ERR); } } @@ -282,18 +282,18 @@ if ($action == "set") $dir = "mysql/tables/"; $okkeys = 0; - $handle=opendir($dir); - dolibarr_install_syslog("step2: open keys directory " . $dir . " handle=" . $handle); + $handle = opendir($dir); + dolibarr_install_syslog("step2: open keys directory ".$dir." handle=".$handle); $tablefound = 0; - $tabledata=array(); + $tabledata = array(); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file)) { $tablefound++; - $tabledata[]=$file; + $tabledata[] = $file; } } closedir($handle); @@ -301,7 +301,7 @@ if ($action == "set") // Sort list of sql files on alphabetical order (load order is important) sort($tabledata); - foreach($tabledata as $file) + foreach ($tabledata as $file) { $name = substr($file, 0, dol_strlen($file) - 4); //print ""; @@ -316,54 +316,54 @@ if ($action == "set") // Special case of lines allowed for some version only if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) { - $versioncommande=explode('.', $reg[1]); + $versioncommande = explode('.', $reg[1]); //print var_dump($versioncommande); //print var_dump($versionarray); if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0) { // Version qualified, delete SQL comments - $buf=preg_replace('/^--\sV([0-9\.]+)/i', '', $buf); + $buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf); //print "Ligne $i qualifiee par version: ".$buf.'
      '; } } if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) { - $versioncommande=explode('.', $reg[1]); + $versioncommande = explode('.', $reg[1]); //print var_dump($versioncommande); //print var_dump($versionarray); if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0) { // Version qualified, delete SQL comments - $buf=preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf); + $buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf); //print "Ligne $i qualifiee par version: ".$buf.'
      '; } } // Ajout ligne si non commentaire - if (! preg_match('/^--/i', $buf)) $buffer .= $buf; + if (!preg_match('/^--/i', $buf)) $buffer .= $buf; } fclose($fp); // Si plusieurs requetes, on boucle sur chaque - $listesql=explode(';', $buffer); + $listesql = explode(';', $buffer); foreach ($listesql as $req) { - $buffer=trim($req); + $buffer = trim($req); if ($buffer) { // Replace the prefix tables if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); + $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } //print ""; $requestnb++; - dolibarr_install_syslog("step2: request: " . $buffer); - $resql=$db->query($buffer, 0, 'dml'); + dolibarr_install_syslog("step2: request: ".$buffer); + $resql = $db->query($buffer, 0, 'dml'); if ($resql) { //print ""; @@ -398,7 +398,7 @@ if ($action == "set") print ""; print '"; $error++; - dolibarr_install_syslog("step2: failed to open file " . $dir . $file, LOG_ERR); + dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR); } } @@ -419,20 +419,20 @@ if ($action == "set") if ($ok && $createfunctions) { // For this file, we use a directory according to database type - if ($choix==1) $dir = "mysql/functions/"; - elseif ($choix==2) $dir = "pgsql/functions/"; - elseif ($choix==3) $dir = "mssql/functions/"; - elseif ($choix==4) { $dir = "sqlite3/functions/"; } + if ($choix == 1) $dir = "mysql/functions/"; + elseif ($choix == 2) $dir = "pgsql/functions/"; + elseif ($choix == 3) $dir = "mssql/functions/"; + elseif ($choix == 4) { $dir = "sqlite3/functions/"; } // Creation donnees $file = "functions.sql"; if (file_exists($dir.$file)) { $fp = fopen($dir.$file, "r"); - dolibarr_install_syslog("step2: open function file " . $dir . $file . " handle=" . $fp); + dolibarr_install_syslog("step2: open function file ".$dir.$file." handle=".$fp); if ($fp) { - $buffer=''; + $buffer = ''; while (!feof($fp)) { $buf = fgets($fp, 4096); @@ -446,20 +446,20 @@ if ($action == "set") //$buffer=preg_replace('/;\';/',";'§",$buffer); // If several requests, we loop on each of them - $listesql=explode('§', $buffer); + $listesql = explode('§', $buffer); foreach ($listesql as $buffer) { - $buffer=trim($buffer); + $buffer = trim($buffer); if ($buffer) { // Replace the prefix in table names if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); + $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } - dolibarr_install_syslog("step2: request: " . $buffer); + dolibarr_install_syslog("step2: request: ".$buffer); print "\n"; - $resql=$db->query($buffer, 0, 'dml'); + $resql = $db->query($buffer, 0, 'dml'); if ($resql) { $ok = 1; @@ -494,7 +494,7 @@ if ($action == "set") else { print ''; - $ok = 1 ; + $ok = 1; } } } @@ -511,23 +511,23 @@ if ($action == "set") $dir = "mysql/data/"; // Insert data - $handle=opendir($dir); - dolibarr_install_syslog("step2: open directory data " . $dir . " handle=" . $handle); + $handle = opendir($dir); + dolibarr_install_syslog("step2: open directory data ".$dir." handle=".$handle); $tablefound = 0; - $tabledata=array(); + $tabledata = array(); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) { - if (preg_match('/^llx_accounting_account_/', $file)) continue; // We discard data file of chart of account. Will be loaded when a chart is selected. + if (preg_match('/^llx_accounting_account_/', $file)) continue; // We discard data file of chart of account. Will be loaded when a chart is selected. //print 'x'.$file.'-'.$createdata.'
      '; if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) { $tablefound++; - $tabledata[]=$file; + $tabledata[] = $file; } } } @@ -536,17 +536,17 @@ if ($action == "set") // Sort list of data files on alphabetical order (load order is important) sort($tabledata); - foreach($tabledata as $file) + foreach ($tabledata as $file) { $name = substr($file, 0, dol_strlen($file) - 4); $fp = fopen($dir.$file, "r"); - dolibarr_install_syslog("step2: open data file " . $dir . $file . " handle=" . $fp); + dolibarr_install_syslog("step2: open data file ".$dir.$file." handle=".$fp); if ($fp) { - $arrayofrequests=array(); - $linefound=0; - $linegroup=0; - $sizeofgroup=1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1. + $arrayofrequests = array(); + $linefound = 0; + $linegroup = 0; + $sizeofgroup = 1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1. // Load all requests while (!feof($fp)) @@ -561,30 +561,30 @@ if ($action == "set") { $linegroup++; } - if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup]=$buffer; - else $arrayofrequests[$linegroup].=" ".$buffer; + if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup] = $buffer; + else $arrayofrequests[$linegroup] .= " ".$buffer; $linefound++; } } fclose($fp); - dolibarr_install_syslog("step2: found " . $linefound . " records, defined " . count($arrayofrequests) . " group(s)."); + dolibarr_install_syslog("step2: found ".$linefound." records, defined ".count($arrayofrequests)." group(s)."); - $okallfile=1; + $okallfile = 1; $db->begin(); // We loop on each requests of file - foreach($arrayofrequests as $buffer) + foreach ($arrayofrequests as $buffer) { // Replace the prefix tables if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); + $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } //dolibarr_install_syslog("step2: request: " . $buffer); - $resql=$db->query($buffer, 1); + $resql = $db->query($buffer, 1); if ($resql) { //$db->free($resql); // Not required as request we launch here does not return memory needs. @@ -617,7 +617,7 @@ if ($action == "set") else { print ''; - $ok = 1; // Data loading are not blocking errors + $ok = 1; // Data loading are not blocking errors } } print '
      "; print $langs->trans("ServerConnection")." : ".$conf->db->host.'Ok
      Failed to select database ".$conf->db->name.'Error
      '.$langs->trans("DatabaseVersion").''.$version.'
      '.join('.',$versionarray).'
      '.join('.',$versionarray).'
      Creation de la table $name/td>"; $requestnb++; - dolibarr_install_syslog("step2: request: " . $buffer); - $resql=$db->query($buffer, 0, 'dml'); + dolibarr_install_syslog("step2: request: ".$buffer); + $resql = $db->query($buffer, 0, 'dml'); if ($resql) { // print "OK requete ==== $buffer
      '.$langs->trans("Error").' Failed to open file '.$dir.$file.'
      '.$langs->trans("ErrorFailedToFindSomeFiles", $dir).'Error
      Creation de la table $name
      Creation des cles et index de la table $name: '$buffer'OK requete ==== $buffer
      '.$langs->trans("Error")." Failed to open file ".$dir.$file."
      Error
      Error
      '; @@ -628,8 +628,8 @@ else } -$ret=0; -if (!$ok && isset($argv[1])) $ret=1; +$ret = 0; +if (!$ok && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step2: end"); @@ -653,7 +653,7 @@ $out .= ''; print $out; -pFooter($ok?0:1, $setuplang); +pFooter($ok ? 0 : 1, $setuplang); if (isset($db) && is_object($db)) $db->close(); diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index b8feb89d246..b780f9d3b0f 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -32,15 +32,15 @@ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; global $langs; -$setuplang=GETPOST('selectlang', 'aZ09', 3)?GETPOST('selectlang', 'aZ09', 3):(empty($argv[1])?'auto':$argv[1]); +$setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[1]) ? 'auto' : $argv[1]); $langs->setDefaultLang($setuplang); $langs->loadLangs(array("admin", "install")); // Now we load forced value from install.forced.php file. -$useforcedwizard=false; -$forcedfile="./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; +$useforcedwizard = false; +$forcedfile = "./install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -48,7 +48,7 @@ if (@file_exists($forcedfile)) { dolibarr_install_syslog("- step4: entering step4.php page"); -$error=0; +$error = 0; $ok = 0; @@ -60,7 +60,7 @@ $ok = 0; pHeader($langs->trans("AdminAccountCreation"), "step5"); // Test if we can run a first install process -if (! is_writable($conffile)) +if (!is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); pFooter(1, $setuplang, 'jscheckparam'); @@ -75,12 +75,12 @@ print $langs->trans("LastStepDesc").'

      '; print ''; -$db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); +$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); if ($db->ok) { print ''; + print ''; print ''; print ''; $sql = "SELECT SUM(amount_capital) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan"; - $sql.= " WHERE fk_loan = ".$chid; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan"; + $sql .= " WHERE fk_loan = ".$chid; $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); } print ''; - print ''; + print ''; print ''; print '
      '; - print '
      '; print '
      '; @@ -91,7 +91,7 @@ if ($db->ok) { print '
      '; print '
      '.$langs->trans("PasswordsMismatch").'
      '; - $error=0; // We show button + $error = 0; // We show button } if (isset($_GET["error"]) && $_GET["error"] == 2) @@ -100,19 +100,19 @@ if ($db->ok) print '
      '; print $langs->trans("PleaseTypePassword"); print '
      '; - $error=0; // We show button + $error = 0; // We show button } if (isset($_GET["error"]) && $_GET["error"] == 3) { print '
      '; print '
      '.$langs->trans("PleaseTypeALogin").'
      '; - $error=0; // We show button + $error = 0; // We show button } } -$ret=0; -if ($error && isset($argv[1])) $ret=1; +$ret = 0; +if ($error && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step4: end"); diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index fcb19b91421..1609035e415 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -28,42 +28,42 @@ include_once 'inc.php'; if (file_exists($conffile)) include_once $conffile; -require_once $dolibarr_main_document_root . '/core/lib/admin.lib.php'; -require_once $dolibarr_main_document_root . '/core/lib/security.lib.php'; // for dol_hash +require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; +require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash global $langs; -$versionfrom=GETPOST("versionfrom", 'alpha', 3)?GETPOST("versionfrom", 'alpha', 3):(empty($argv[1])?'':$argv[1]); -$versionto=GETPOST("versionto", 'alpha', 3)?GETPOST("versionto", 'alpha', 3):(empty($argv[2])?'':$argv[2]); -$setuplang=GETPOST('selectlang', 'aZ09', 3)?GETPOST('selectlang', 'aZ09', 3):(empty($argv[3])?'auto':$argv[3]); +$versionfrom = GETPOST("versionfrom", 'alpha', 3) ?GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]); +$versionto = GETPOST("versionto", 'alpha', 3) ?GETPOST("versionto", 'alpha', 3) : (empty($argv[2]) ? '' : $argv[2]); +$setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[3]) ? 'auto' : $argv[3]); $langs->setDefaultLang($setuplang); -$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):(empty($argv[4])?'':$argv[4]); +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : (empty($argv[4]) ? '' : $argv[4]); // Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install // or MAIN_VERSION_LAST_UPGRADE for upgrade. -$targetversion=DOL_VERSION; // If it's latest upgrade -if (! empty($action) && preg_match('/upgrade/i', $action)) // If it's an old upgrade +$targetversion = DOL_VERSION; // If it's latest upgrade +if (!empty($action) && preg_match('/upgrade/i', $action)) // If it's an old upgrade { - $tmp=explode('_', $action, 2); - if ($tmp[0]=='upgrade') + $tmp = explode('_', $action, 2); + if ($tmp[0] == 'upgrade') { - if (! empty($tmp[1])) $targetversion=$tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta' - else $targetversion=DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION + if (!empty($tmp[1])) $targetversion = $tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta' + else $targetversion = DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION } } $langs->loadLangs(array("admin", "install")); -$login = GETPOST('login', 'alpha')?GETPOST('login', 'alpha'):(empty($argv[5])?'':$argv[5]); -$pass = GETPOST('pass', 'alpha')?GETPOST('pass', 'alpha'):(empty($argv[6])?'':$argv[6]); -$pass_verif = GETPOST('pass_verif', 'alpha')?GETPOST('pass_verif', 'alpha'):(empty($argv[7])?'':$argv[7]); -$force_install_lockinstall = (int) (! empty($force_install_lockinstall)?$force_install_lockinstall:(GETPOST('installlock', 'aZ09')?GETPOST('installlock', 'aZ09'):(empty($argv[8])?'':$argv[8]))); +$login = GETPOST('login', 'alpha') ?GETPOST('login', 'alpha') : (empty($argv[5]) ? '' : $argv[5]); +$pass = GETPOST('pass', 'alpha') ?GETPOST('pass', 'alpha') : (empty($argv[6]) ? '' : $argv[6]); +$pass_verif = GETPOST('pass_verif', 'alpha') ?GETPOST('pass_verif', 'alpha') : (empty($argv[7]) ? '' : $argv[7]); +$force_install_lockinstall = (int) (!empty($force_install_lockinstall) ? $force_install_lockinstall : (GETPOST('installlock', 'aZ09') ?GETPOST('installlock', 'aZ09') : (empty($argv[8]) ? '' : $argv[8]))); -$success=0; +$success = 0; -$useforcedwizard=false; -$forcedfile="./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; +$useforcedwizard = false; +$forcedfile = "./install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -77,7 +77,7 @@ if (@file_exists($forcedfile)) { dolibarr_install_syslog("- step5: entering step5.php page"); -$error=0; +$error = 0; /* * Actions @@ -86,17 +86,17 @@ $error=0; // If install, check password and password_verification used to create admin account if ($action == "set") { if ($pass <> $pass_verif) { - header("Location: step4.php?error=1&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : '')); + header("Location: step4.php?error=1&selectlang=$setuplang".(isset($login) ? '&login='.$login : '')); exit; } if (dol_strlen(trim($pass)) == 0) { - header("Location: step4.php?error=2&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : '')); + header("Location: step4.php?error=2&selectlang=$setuplang".(isset($login) ? '&login='.$login : '')); exit; } if (dol_strlen(trim($login)) == 0) { - header("Location: step4.php?error=3&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : '')); + header("Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ? '&login='.$login : '')); exit; } } @@ -110,7 +110,7 @@ pHeader($langs->trans("SetupEnd"), "step5"); print '
      '; // Test if we can run a first install process -if (empty($versionfrom) && empty($versionto) && ! is_writable($conffile)) +if (empty($versionfrom) && empty($versionto) && !is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); pFooter(1, $setuplang, 'jscheckparam'); @@ -119,17 +119,17 @@ if (empty($versionfrom) && empty($versionto) && ! is_writable($conffile)) if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { - $error=0; + $error = 0; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } @@ -140,14 +140,14 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption)?$dolibarr_main_db_encryption:''; - $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey)?$dolibarr_main_db_cryptkey:''; + $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption : ''; + $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey : ''; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); + $hookmanager = new HookManager($db); $ok = 0; @@ -155,64 +155,64 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) if ($action == "set") { // Active module user - $modName='modUser'; - $file = $modName . ".class.php"; - dolibarr_install_syslog('step5: load module user ' . DOL_DOCUMENT_ROOT . "/core/modules/" . $file, LOG_INFO); - include_once DOL_DOCUMENT_ROOT ."/core/modules/".$file; + $modName = 'modUser'; + $file = $modName.".class.php"; + dolibarr_install_syslog('step5: load module user '.DOL_DOCUMENT_ROOT."/core/modules/".$file, LOG_INFO); + include_once DOL_DOCUMENT_ROOT."/core/modules/".$file; $objMod = new $modName($db); - $result=$objMod->init(); - if (! $result) print 'ERROR in activating module file='.$file; + $result = $objMod->init(); + if (!$result) print 'ERROR in activating module file='.$file; if ($db->connected) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Create admin user - include_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Set default encryption to yes, generate a salt and set default encryption algorythm (but only if there is no user yet into database) $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $resql = $db->query($sql); if ($resql) { - $numrows=$db->num_rows($resql); + $numrows = $db->num_rows($resql); if ($numrows == 0) { // Define default setup for password encryption dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities if (function_exists('password_hash')) - dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'password_hash', 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'password_hash', 'chaine', 0, '', 0); // All entities else - dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities } dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO); } // Create user used to create the admin user - $createuser=new User($db); - $createuser->id=0; - $createuser->admin=1; + $createuser = new User($db); + $createuser->id = 0; + $createuser->admin = 1; // Set admin user $newuser = new User($db); - $newuser->lastname='SuperAdmin'; - $newuser->firstname=''; + $newuser->lastname = 'SuperAdmin'; + $newuser->firstname = ''; $newuser->login = $login; $newuser->pass = $pass; - $newuser->admin=1; - $newuser->entity=0; + $newuser->admin = 1; + $newuser->entity = 0; - $conf->global->USER_MAIL_REQUIRED=0; // Force global option to be sure to create a new user with no email - $result=$newuser->create($createuser, 1); + $conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email + $result = $newuser->create($createuser, 1); if ($result > 0) { - print $langs->trans("AdminLoginCreatedSuccessfuly", $login) . "
      "; + print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."
      "; $success = 1; } else @@ -220,12 +220,12 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) if ($newuser->error == 'ErrorLoginAlreadyExists') { dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING); - print '
      ' . $langs->trans("AdminLoginAlreadyExists", $login) . "

      "; + print '
      '.$langs->trans("AdminLoginAlreadyExists", $login)."

      "; $success = 1; } else { - dolibarr_install_syslog('step5: FailedToCreateAdminLogin ' . $newuser->error, LOG_ERR); + dolibarr_install_syslog('step5: FailedToCreateAdminLogin '.$newuser->error, LOG_ERR); print '
      '.$langs->trans("FailedToCreateAdminLogin").' '.$newuser->error.'


      '; } } @@ -234,11 +234,11 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { // Insert MAIN_VERSION_FIRST_INSTALL in a dedicated transaction. So if it fails (when first install was already done), we can do other following requests. $db->begin(); - dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to ' . $targetversion, LOG_DEBUG); - $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_FIRST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when first install',0)"); + dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to '.$targetversion, LOG_DEBUG); + $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_FIRST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when first install',0)"); if ($resql) { - $conf->global->MAIN_VERSION_FIRST_INSTALL=$targetversion; + $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion; $db->commit(); } else @@ -249,46 +249,46 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $db->begin(); - dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to ' . $targetversion, LOG_DEBUG); - $resql=$db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'"); - if (! $resql) dol_print_error($db, 'Error in setup program'); - $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when last install',0)"); - if (! $resql) dol_print_error($db, 'Error in setup program'); - $conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion; + dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG); + $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'"); + if (!$resql) dol_print_error($db, 'Error in setup program'); + $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when last install',0)"); + if (!$resql) dol_print_error($db, 'Error in setup program'); + $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion; if ($useforcedwizard) { dolibarr_install_syslog('step5: set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG); - $resql=$db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'"); - if (! $resql) dol_print_error($db, 'Error in setup program'); - $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING', 1).",".$db->encrypt(1, 1).",'chaine',1,'Disable install warnings',0)"); - if (! $resql) dol_print_error($db, 'Error in setup program'); - $conf->global->MAIN_REMOVE_INSTALL_WARNING=1; + $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'"); + if (!$resql) dol_print_error($db, 'Error in setup program'); + $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING', 1).",".$db->encrypt(1, 1).",'chaine',1,'Disable install warnings',0)"); + if (!$resql) dol_print_error($db, 'Error in setup program'); + $conf->global->MAIN_REMOVE_INSTALL_WARNING = 1; } // If we ask to force some modules to be enabled - if (! empty($force_install_module)) + if (!empty($force_install_module)) { - if (! defined('DOL_DOCUMENT_ROOT') && ! empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); + if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); - $tmparray=explode(',', $force_install_module); + $tmparray = explode(',', $force_install_module); foreach ($tmparray as $modtoactivate) { - $modtoactivatenew=preg_replace('/\.class\.php$/i', '', $modtoactivate); + $modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate); print $langs->trans("ActivateModule", $modtoactivatenew).'
      '; - $file=$modtoactivatenew.'.class.php'; - dolibarr_install_syslog('step5: activate module file=' . $file); - $res=dol_include_once("/core/modules/".$file); + $file = $modtoactivatenew.'.class.php'; + dolibarr_install_syslog('step5: activate module file='.$file); + $res = dol_include_once("/core/modules/".$file); - $res=activateModule($modtoactivatenew, 1); - if (! empty($res['errors'])) print 'ERROR in activating module file='.$file; + $res = activateModule($modtoactivatenew, 1); + if (!empty($res['errors'])) print 'ERROR in activating module file='.$file; } } dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const'); - $resql=$db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'"); - if (! $resql) dol_print_error($db, 'Error in setup program'); + $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'"); + if (!$resql) dol_print_error($db, 'Error in setup program'); $db->commit(); } @@ -305,31 +305,31 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database - $tagdatabase=false; - if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase=true; // We don't know what it was before, so now we consider we are version choosed. + $tagdatabase = false; + if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase = true; // We don't know what it was before, so now we consider we are version choosed. else { - $mainversionlastupgradearray=preg_split('/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE); - $targetversionarray=preg_split('/[.-]/', $targetversion); - if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) $tagdatabase=true; + $mainversionlastupgradearray = preg_split('/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE); + $targetversionarray = preg_split('/[.-]/', $targetversion); + if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) $tagdatabase = true; } if ($tagdatabase) { - dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_UPGRADE const to value ' . $targetversion); - $resql=$db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'"); - if (! $resql) dol_print_error($db, 'Error in setup program'); - $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) VALUES (".$db->encrypt('MAIN_VERSION_LAST_UPGRADE', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version for last upgrade',0)"); - if (! $resql) dol_print_error($db, 'Error in setup program'); - $conf->global->MAIN_VERSION_LAST_UPGRADE=$targetversion; + dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion); + $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'"); + if (!$resql) dol_print_error($db, 'Error in setup program'); + $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) VALUES (".$db->encrypt('MAIN_VERSION_LAST_UPGRADE', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version for last upgrade',0)"); + if (!$resql) dol_print_error($db, 'Error in setup program'); + $conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion; } else { - dolibarr_install_syslog('step5: we run an upgrade to version ' . $targetversion . ' but database was already upgraded to ' . $conf->global->MAIN_VERSION_LAST_UPGRADE . '. We keep MAIN_VERSION_LAST_UPGRADE as it is.'); + dolibarr_install_syslog('step5: we run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.'); } } else @@ -343,7 +343,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) } // May fail if parameter already defined - $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) VALUES (".$db->encrypt('MAIN_LANG_DEFAULT', 1).",".$db->encrypt($setuplang, 1).",'chaine',0,'Default language',1)"); + $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) VALUES (".$db->encrypt('MAIN_LANG_DEFAULT', 1).",".$db->encrypt($setuplang, 1).",'chaine',0,'Default language',1)"); //if (! $resql) dol_print_error($db,'Error in setup program'); $db->close(); @@ -361,20 +361,20 @@ if ($action == "set" && $success) // Install is finished print $langs->trans("SystemIsInstalled")."
      "; - $createlock=0; + $createlock = 0; - if (! empty($force_install_lockinstall) || ! empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) + if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) { // Install is finished, we create the lock file - $lockfile=DOL_DATA_ROOT.'/install.lock'; + $lockfile = DOL_DATA_ROOT.'/install.lock'; $fp = @fopen($lockfile, "w"); if ($fp) { - if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall=444; // For backward compatibility + if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); @chmod($lockfile, octdec($force_install_lockinstall)); - $createlock=1; + $createlock = 1; } } if (empty($createlock)) @@ -386,7 +386,7 @@ if ($action == "set" && $success) print $langs->trans("YouNeedToPersonalizeSetup")."

      "; - print '
      '; + print ''; } @@ -398,7 +398,7 @@ if ($action == "set" && $success) print $langs->trans("MigrationNotFinished").'
      '; print "
      "; - print '
      '; + print ''; } @@ -411,20 +411,20 @@ elseif (empty($action) || preg_match('/upgrade/i', $action)) // Upgrade is finished print $langs->trans("SystemIsUpgraded")."
      "; - $createlock=0; + $createlock = 0; - if (! empty($force_install_lockinstall) || ! empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) + if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) { // Upgrade is finished, we create the lock file - $lockfile=DOL_DATA_ROOT.'/install.lock'; + $lockfile = DOL_DATA_ROOT.'/install.lock'; $fp = @fopen($lockfile, "w"); if ($fp) { - if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall=444; // For backward compatibility + if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); @chmod($lockfile, octdec($force_install_lockinstall)); - $createlock=1; + $createlock = 1; } } if (empty($createlock)) @@ -434,7 +434,7 @@ elseif (empty($action) || preg_match('/upgrade/i', $action)) print "

      "; - print '
      '; + print '
      '; } @@ -459,8 +459,8 @@ else // Clear cache files clearstatcache(); -$ret=0; -if ($error && isset($argv[1])) $ret=1; +$ret = 0; +if ($error && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step5: Dolibarr setup finished"); diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index fb052bca77e..b71707bef4b 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -37,7 +37,7 @@ */ include_once 'inc.php'; -if (! file_exists($conffile)) +if (!file_exists($conffile)) { print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } @@ -46,49 +46,49 @@ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; global $langs; -$grant_query=''; +$grant_query = ''; $step = 2; $ok = 0; // Cette page peut etre longue. On augmente le delai autorise. // Ne fonctionne que si on est pas en safe_mode. -$err=error_reporting(); +$err = error_reporting(); error_reporting(0); @set_time_limit(300); error_reporting($err); -$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):'auto'; +$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : 'auto'; $langs->setDefaultLang($setuplang); -$versionfrom=GETPOST("versionfrom", 'alpha', 3)?GETPOST("versionfrom", 'alpha', 3):(empty($argv[1])?'':$argv[1]); -$versionto=GETPOST("versionto", 'alpha', 3)?GETPOST("versionto", '', 3):(empty($argv[2])?'':$argv[2]); -$dirmodule=((GETPOST("dirmodule", 'alpha', 3) && GETPOST("dirmodule", 'alpha', 3) != 'ignoredbversion'))?GETPOST("dirmodule", 'alpha', 3):((empty($argv[3]) || $argv[3] == 'ignoredbversion')?'':$argv[3]); -$ignoredbversion=(GETPOST('ignoredbversion', 'alpha', 3)=='ignoredbversion')?GETPOST('ignoredbversion', 'alpha', 3):((empty($argv[3]) || $argv[3] != 'ignoredbversion')?'':$argv[3]); +$versionfrom = GETPOST("versionfrom", 'alpha', 3) ?GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]); +$versionto = GETPOST("versionto", 'alpha', 3) ?GETPOST("versionto", '', 3) : (empty($argv[2]) ? '' : $argv[2]); +$dirmodule = ((GETPOST("dirmodule", 'alpha', 3) && GETPOST("dirmodule", 'alpha', 3) != 'ignoredbversion')) ?GETPOST("dirmodule", 'alpha', 3) : ((empty($argv[3]) || $argv[3] == 'ignoredbversion') ? '' : $argv[3]); +$ignoredbversion = (GETPOST('ignoredbversion', 'alpha', 3) == 'ignoredbversion') ?GETPOST('ignoredbversion', 'alpha', 3) : ((empty($argv[3]) || $argv[3] != 'ignoredbversion') ? '' : $argv[3]); $langs->loadLangs(array("admin", "install", "other", "errors")); -if ($dolibarr_main_db_type == "mysqli") $choix=1; -if ($dolibarr_main_db_type == "pgsql") $choix=2; -if ($dolibarr_main_db_type == "mssql") $choix=3; +if ($dolibarr_main_db_type == "mysqli") $choix = 1; +if ($dolibarr_main_db_type == "pgsql") $choix = 2; +if ($dolibarr_main_db_type == "mssql") $choix = 3; dolibarr_install_syslog("--- upgrade: Entering upgrade.php page"); -if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); +if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); /* * View */ -if (! $versionfrom && ! $versionto) +if (!$versionfrom && !$versionto) { print 'Error: Parameter versionfrom or versionto missing.'."\n"; print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); - $path=__DIR__.'/'; + $path = __DIR__.'/'; if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; @@ -99,27 +99,27 @@ if (! $versionfrom && ! $versionto) pHeader('', "upgrade2", GETPOST('action', 'aZ09'), 'versionfrom='.$versionfrom.'&versionto='.$versionto); -$actiondone=0; +$actiondone = 0; // Action to launch the migrate script -if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { - $actiondone=1; + $actiondone = 1; print '

      Database '.$langs->trans("DatabaseMigration").'

      '; print ''; - $error=0; + $error = 0; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } @@ -133,104 +133,104 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $conf->db->pass = $dolibarr_main_db_pass; // Load type and crypt key - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); + $hookmanager = new HookManager($db); if ($db->connected) { print '\n"; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ServerConnection") . ": $dolibarr_main_db_host " . $langs->transnoentities("OK")); + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK")); $ok = 1; } else { print "\n"; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } if ($ok) { - if($db->database_selected) + if ($db->database_selected) { print '\n"; - dolibarr_install_syslog("upgrade: Database connection successful: " . $dolibarr_main_db_name); - $ok=1; + dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name); + $ok = 1; } else { print "\n"; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); - $ok=0; + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); + $ok = 0; } } // Affiche version if ($ok) { - $version=$db->getVersion(); - $versionarray=$db->getVersionArray(); + $version = $db->getVersion(); + $versionarray = $db->getVersionArray(); print ''; print ''; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ServerVersion") . ": " .$version); + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion").": ".$version); if ($db->type == 'mysqli' && function_exists('mysqli_get_charset')) { $tmparray = $db->db->get_charset(); print ''; print ''; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ClientCharset") . ": " .$tmparray->charset); + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ClientCharset").": ".$tmparray->charset); print ''; print ''; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ClientCollation") . ": " .$tmparray->collation); + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ClientCollation").": ".$tmparray->collation); } // Test database version requirement - $versionmindb=explode('.', $db::VERSIONMIN); + $versionmindb = explode('.', $db::VERSIONMIN); //print join('.',$versionarray).' - '.join('.',$versionmindb); if (count($versionmindb) && count($versionarray) && versioncompare($versionarray, $versionmindb) < 0) { // Warning: database version too low. print "\n"; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))); - $ok=0; + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))); + $ok = 0; } // Test database version is not forbidden for migration if (empty($ignoredbversion)) { - $dbversion_disallowed=array( - array('type'=>'mysql','version'=>array(5,5,40)), - array('type'=>'mysqli','version'=>array(5,5,40)) //, + $dbversion_disallowed = array( + array('type'=>'mysql', 'version'=>array(5, 5, 40)), + array('type'=>'mysqli', 'version'=>array(5, 5, 40)) //, //array('type'=>'mysql','version'=>array(5,5,41)), //array('type'=>'mysqli','version'=>array(5,5,41)) ); - $listofforbiddenversion=''; + $listofforbiddenversion = ''; foreach ($dbversion_disallowed as $dbversion_totest) { - if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion.=($listofforbiddenversion?', ':'').join('.', $dbversion_totest['version']); + if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']); } foreach ($dbversion_disallowed as $dbversion_totest) { //print $db->type.' - '.join('.',$versionarray).' - '.versioncompare($dbversion_totest['version'],$versionarray)."
      \n"; if ($dbversion_totest['type'] == $db->type - && (versioncompare($dbversion_totest['version'], $versionarray) == 0 || versioncompare($dbversion_totest['version'], $versionarray)<=-4 || versioncompare($dbversion_totest['version'], $versionarray)>=4) + && (versioncompare($dbversion_totest['version'], $versionarray) == 0 || versioncompare($dbversion_totest['version'], $versionarray) <= -4 || versioncompare($dbversion_totest['version'], $versionarray) >= 4) ) { // Warning: database version too low. print '\n"; - dolibarr_install_syslog("upgrade: " . $langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)); - $ok=0; + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)); + $ok = 0; break; } } @@ -250,7 +250,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a */ if ($ok && preg_match('/mysql/', $db->type)) { - $versioncommande=array(4,0,0); + $versioncommande = array(4, 0, 0); if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0) // Si mysql >= 4.0 { @@ -258,11 +258,11 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Suppression vieilles contraintes sans noms et en doubles // Les contraintes indesirables ont un nom qui commence par 0_ ou se termine par ibfk_999 - $listtables=array( + $listtables = array( MAIN_DB_PREFIX.'adherent_options', MAIN_DB_PREFIX.'bank_class', MAIN_DB_PREFIX.'c_ecotaxe', - MAIN_DB_PREFIX.'c_methode_commande_fournisseur', // table renamed + MAIN_DB_PREFIX.'c_methode_commande_fournisseur', // table renamed MAIN_DB_PREFIX.'c_input_method' ); @@ -277,18 +277,18 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $resql = $db->query($sql); if ($resql) { - $values=$db->fetch_array($resql); - $i=0; - $createsql=$values[1]; + $values = $db->fetch_array($resql); + $i = 0; + $createsql = $values[1]; while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i', $createsql, $reg) && $i < 100) { - $sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1]; + $sqldrop = "ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1]; $resqldrop = $db->query($sqldrop); if ($resqldrop) { print '\n"; } - $createsql=preg_replace('/CONSTRAINT `'.$reg[1].'`/i', 'XXX', $createsql); + $createsql = preg_replace('/CONSTRAINT `'.$reg[1].'`/i', 'XXX', $createsql); $i++; } $db->free($resql); @@ -310,28 +310,28 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a */ if ($ok) { - $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver - if (! empty($dirmodule)) $dir=dol_buildpath('/'.$dirmodule.'/sql/', 0); + $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver + if (!empty($dirmodule)) $dir = dol_buildpath('/'.$dirmodule.'/sql/', 0); dolibarr_install_syslog("Scan sql files for migration files in ".$dir); // Clean last part to exclude minor version x.y.z -> x.y - $newversionfrom=preg_replace('/(\.[0-9]+)$/i', '.0', $versionfrom); - $newversionto=preg_replace('/(\.[0-9]+)$/i', '.0', $versionto); + $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.0', $versionfrom); + $newversionto = preg_replace('/(\.[0-9]+)$/i', '.0', $versionto); - $filelist=array(); + $filelist = array(); $i = 0; $ok = 0; - $from='^'.$newversionfrom; - $to=$newversionto.'\.sql$'; + $from = '^'.$newversionfrom; + $to = $newversionto.'\.sql$'; // Get files list - $filesindir=array(); - $handle=opendir($dir); + $filesindir = array(); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (preg_match('/\.sql$/i', $file)) $filesindir[]=$file; + if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file; } sort($filesindir); } @@ -341,15 +341,15 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Define which file to run - foreach($filesindir as $file) + foreach ($filesindir as $file) { if (preg_match('/'.$from.'/i', $file)) { - $filelist[]=$file; + $filelist[] = $file; } elseif (preg_match('/'.$to.'/i', $file)) // First test may be false if we migrate from x.y.* to x.y.* { - $filelist[]=$file; + $filelist[] = $file; } } @@ -359,10 +359,10 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } else { - $listoffileprocessed=array(); // Protection to avoid to process twice the same file + $listoffileprocessed = array(); // Protection to avoid to process twice the same file // Loop on each migrate files - foreach($filelist as $file) + foreach ($filelist as $file) { if (in_array($dir.$file, $listoffileprocessed)) continue; @@ -370,25 +370,25 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a print ''."\n"; // Run sql script - $ok=run_sql($dir.$file, 0, '', 1); - $listoffileprocessed[$dir.$file]=$dir.$file; + $ok = run_sql($dir.$file, 0, '', 1); + $listoffileprocessed[$dir.$file] = $dir.$file; // Scan if there is migration scripts that depends of Dolibarr version // for modules htdocs/module/sql or htdocs/custom/module/sql (files called "dolibarr_x.y.z-a.b.c.sql") $modulesfile = array(); foreach ($conf->file->dol_document_root as $type => $dirroot) { - $handlemodule=@opendir($dirroot); // $dirroot may be '..' + $handlemodule = @opendir($dirroot); // $dirroot may be '..' if (is_resource($handlemodule)) { - while (($filemodule = readdir($handlemodule))!==false) + while (($filemodule = readdir($handlemodule)) !== false) { - if (! preg_match('/\./', $filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories. + if (!preg_match('/\./', $filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories. { //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; - if (is_file($dirroot . '/' . $filemodule . '/sql/dolibarr_'.$file)) + if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) { - $modulesfile[$dirroot . '/' . $filemodule . '/sql/dolibarr_'.$file] = '/' . $filemodule . '/sql/dolibarr_'.$file; + $modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file] = '/'.$filemodule.'/sql/dolibarr_'.$file; } } } @@ -404,8 +404,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a print ''."\n"; // Run sql script - $okmodule=run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not. - $listoffileprocessed[$modulefilelong]=$modulefilelong; + $okmodule = run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not. + $listoffileprocessed[$modulefilelong] = $modulefilelong; } } } @@ -421,13 +421,13 @@ if (empty($actiondone)) print '
      '.$langs->trans("ErrorWrongParameters").'
      '; } -$ret=0; -if (! $ok && isset($argv[1])) $ret=1; +$ret = 0; +if (!$ok && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); -dolibarr_install_syslog("--- upgrade: end ".((! $ok && empty($_GET["ignoreerrors"])) || $dirmodule)); -$nonext = (! $ok && empty($_GET["ignoreerrors"]))?2:0; -if ($dirmodule) $nonext=1; +dolibarr_install_syslog("--- upgrade: end ".((!$ok && empty($_GET["ignoreerrors"])) || $dirmodule)); +$nonext = (!$ok && empty($_GET["ignoreerrors"])) ? 2 : 0; +if ($dirmodule) $nonext = 1; pFooter($nonext, $setuplang); if ($db->connected) $db->close(); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d2f03580391..6825265b529 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -39,52 +39,52 @@ */ include_once 'inc.php'; -if (! file_exists($conffile)) +if (!file_exists($conffile)) { print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } require_once $conffile; -require_once $dolibarr_main_document_root . '/compta/facture/class/facture.class.php'; -require_once $dolibarr_main_document_root . '/comm/propal/class/propal.class.php'; -require_once $dolibarr_main_document_root . '/contrat/class/contrat.class.php'; -require_once $dolibarr_main_document_root . '/commande/class/commande.class.php'; -require_once $dolibarr_main_document_root . '/fourn/class/fournisseur.commande.class.php'; -require_once $dolibarr_main_document_root . '/core/lib/price.lib.php'; -require_once $dolibarr_main_document_root . '/core/class/menubase.class.php'; -require_once $dolibarr_main_document_root . '/core/lib/files.lib.php'; +require_once $dolibarr_main_document_root.'/compta/facture/class/facture.class.php'; +require_once $dolibarr_main_document_root.'/comm/propal/class/propal.class.php'; +require_once $dolibarr_main_document_root.'/contrat/class/contrat.class.php'; +require_once $dolibarr_main_document_root.'/commande/class/commande.class.php'; +require_once $dolibarr_main_document_root.'/fourn/class/fournisseur.commande.class.php'; +require_once $dolibarr_main_document_root.'/core/lib/price.lib.php'; +require_once $dolibarr_main_document_root.'/core/class/menubase.class.php'; +require_once $dolibarr_main_document_root.'/core/lib/files.lib.php'; global $langs; -$grant_query=''; +$grant_query = ''; $step = 2; $error = 0; // Cette page peut etre longue. On augmente le delai autorise. // Ne fonctionne que si on est pas en safe_mode. -$err=error_reporting(); +$err = error_reporting(); error_reporting(0); -if (! empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT)) +if (!empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT)) @set_time_limit((int) $conf->global->MAIN_OVERRIDE_TIME_LIMIT); else @set_time_limit(600); error_reporting($err); -$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):'auto'; +$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : 'auto'; $langs->setDefaultLang($setuplang); -$versionfrom=GETPOST("versionfrom", 'alpha', 3)?GETPOST("versionfrom", 'alpha', 3):(empty($argv[1])?'':$argv[1]); -$versionto=GETPOST("versionto", 'alpha', 3)?GETPOST("versionto", 'alpha', 3):(empty($argv[2])?'':$argv[2]); -$enablemodules=GETPOST("enablemodules", 'alpha', 3)?GETPOST("enablemodules", 'alpha', 3):(empty($argv[3])?'':$argv[3]); +$versionfrom = GETPOST("versionfrom", 'alpha', 3) ?GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]); +$versionto = GETPOST("versionto", 'alpha', 3) ?GETPOST("versionto", 'alpha', 3) : (empty($argv[2]) ? '' : $argv[2]); +$enablemodules = GETPOST("enablemodules", 'alpha', 3) ?GETPOST("enablemodules", 'alpha', 3) : (empty($argv[3]) ? '' : $argv[3]); $langs->loadLangs(array("admin", "install", "bills", "suppliers")); -if ($dolibarr_main_db_type == 'mysqli') $choix=1; -if ($dolibarr_main_db_type == 'pgsql') $choix=2; -if ($dolibarr_main_db_type == 'mssql') $choix=3; +if ($dolibarr_main_db_type == 'mysqli') $choix = 1; +if ($dolibarr_main_db_type == 'pgsql') $choix = 2; +if ($dolibarr_main_db_type == 'mssql') $choix = 3; dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto." ".$enablemodules); -if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); +if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); @@ -453,8 +453,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Scripts for 11.0 - $afterversionarray=explode('.', '10.0.9'); - $beforeversionarray=explode('.', '11.0.9'); + $afterversionarray = explode('.', '10.0.9'); + $beforeversionarray = explode('.', '11.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_users_socialnetworks(); migrate_members_socialnetworks(); @@ -5025,19 +5025,19 @@ function migrate_users_socialnetworks() } $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."user SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd.= ', skype=null'; - $sqlupd.= ', twitter=null'; - $sqlupd.= ', facebook=null'; - $sqlupd.= ', linkedin=null'; - $sqlupd.= ', instagram=null'; - $sqlupd.= ', snapchat=null'; - $sqlupd.= ', googleplus=null'; - $sqlupd.= ', youtube=null'; - $sqlupd.= ', whatsapp=null'; - $sqlupd.= ' WHERE rowid='.$obj->rowid; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; //print $sqlupd."
      "; $resqlupd = $db->query($sqlupd); - if (! $resqlupd) { + if (!$resqlupd) { dol_print_error($db); $error++; } @@ -5045,7 +5045,7 @@ function migrate_users_socialnetworks() } else { $error++; } - if (! $error) { + if (!$error) { $db->commit(); } else { dol_print_error($db); @@ -5116,19 +5116,19 @@ function migrate_members_socialnetworks() } $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."adherent SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd.= ', skype=null'; - $sqlupd.= ', twitter=null'; - $sqlupd.= ', facebook=null'; - $sqlupd.= ', linkedin=null'; - $sqlupd.= ', instagram=null'; - $sqlupd.= ', snapchat=null'; - $sqlupd.= ', googleplus=null'; - $sqlupd.= ', youtube=null'; - $sqlupd.= ', whatsapp=null'; - $sqlupd.= ' WHERE rowid='.$obj->rowid; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; //print $sqlupd."
      "; $resqlupd = $db->query($sqlupd); - if (! $resqlupd) { + if (!$resqlupd) { dol_print_error($db); $error++; } @@ -5136,7 +5136,7 @@ function migrate_members_socialnetworks() } else { $error++; } - if (! $error) { + if (!$error) { $db->commit(); } else { dol_print_error($db); @@ -5210,20 +5210,20 @@ function migrate_contacts_socialnetworks() } $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."socpeople SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd.= ', jabberid=null'; - $sqlupd.= ', skype=null'; - $sqlupd.= ', twitter=null'; - $sqlupd.= ', facebook=null'; - $sqlupd.= ', linkedin=null'; - $sqlupd.= ', instagram=null'; - $sqlupd.= ', snapchat=null'; - $sqlupd.= ', googleplus=null'; - $sqlupd.= ', youtube=null'; - $sqlupd.= ', whatsapp=null'; - $sqlupd.= ' WHERE rowid='.$obj->rowid; + $sqlupd .= ', jabberid=null'; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; //print $sqlupd."
      "; $resqlupd = $db->query($sqlupd); - if (! $resqlupd) { + if (!$resqlupd) { dol_print_error($db); $error++; } @@ -5231,7 +5231,7 @@ function migrate_contacts_socialnetworks() } else { $error++; } - if (! $error) { + if (!$error) { $db->commit(); } else { dol_print_error($db); @@ -5301,19 +5301,19 @@ function migrate_thirdparties_socialnetworks() } $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."societe SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd.= ', skype=null'; - $sqlupd.= ', twitter=null'; - $sqlupd.= ', facebook=null'; - $sqlupd.= ', linkedin=null'; - $sqlupd.= ', instagram=null'; - $sqlupd.= ', snapchat=null'; - $sqlupd.= ', googleplus=null'; - $sqlupd.= ', youtube=null'; - $sqlupd.= ', whatsapp=null'; - $sqlupd.= ' WHERE rowid='.$obj->rowid; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; //print $sqlupd."
      "; $resqlupd = $db->query($sqlupd); - if (! $resqlupd) { + if (!$resqlupd) { dol_print_error($db); $error++; } @@ -5321,7 +5321,7 @@ function migrate_thirdparties_socialnetworks() } else { $error++; } - if (! $error) { + if (!$error) { $db->commit(); } else { dol_print_error($db); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 8102db49f28..82c6521e00f 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -34,30 +34,30 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->expedition_bon->enabled)) +if (!empty($conf->expedition_bon->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -if (! empty($conf->stock->enabled)) +if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("sendings","bills",'deliveries','orders')); +$langs->loadLangs(array("sendings", "bills", 'deliveries', 'orders')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'expedition', $id, 'livraison', 'livraison'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'expedition', $id, 'livraison', 'livraison'); $object = new Livraison($db); $extrafields = new ExtraFields($db); diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index da1fc75b5b2..acfe8b29d05 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -30,8 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; /** @@ -42,22 +42,22 @@ class Livraison extends CommonObject /** * @var string ID to identify managed object */ - public $element="delivery"; + public $element = "delivery"; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element="fk_livraison"; + public $fk_element = "fk_livraison"; /** * @var string Name of table without prefix where object is stored */ - public $table_element="livraison"; + public $table_element = "livraison"; /** * @var int Name of subtable line */ - public $table_element_line="livraisondet"; + public $table_element_line = "livraisondet"; public $brouillon; public $socid; @@ -111,11 +111,11 @@ class Livraison extends CommonObject dol_syslog("Livraison::create"); - if (empty($this->model_pdf)) $this->model_pdf=$conf->global->LIVRAISON_ADDON_PDF; + if (empty($this->model_pdf)) $this->model_pdf = $conf->global->LIVRAISON_ADDON_PDF; $error = 0; - $now=dol_now(); + $now = dol_now(); /* On positionne en mode brouillon le bon de livraison */ $this->brouillon = 1; @@ -125,36 +125,36 @@ class Livraison extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraison ("; - $sql.= "ref"; - $sql.= ", entity"; - $sql.= ", fk_soc"; - $sql.= ", ref_customer"; - $sql.= ", date_creation"; - $sql.= ", fk_user_author"; - $sql.= ", date_delivery"; - $sql.= ", fk_address"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", model_pdf"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ") VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".$this->socid; - $sql.= ", '".$this->db->escape($this->ref_customer)."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_delivery?"'".$this->db->idate($this->date_delivery)."'":"null"); - $sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); - $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"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.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ")"; + $sql .= "ref"; + $sql .= ", entity"; + $sql .= ", fk_soc"; + $sql .= ", ref_customer"; + $sql .= ", date_creation"; + $sql .= ", fk_user_author"; + $sql .= ", date_delivery"; + $sql .= ", fk_address"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", model_pdf"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ") VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".$this->socid; + $sql .= ", '".$this->db->escape($this->ref_customer)."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_delivery ? "'".$this->db->idate($this->date_delivery)."'" : "null"); + $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); + $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "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 .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ")"; dol_syslog("Livraison::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison"); @@ -162,14 +162,14 @@ class Livraison extends CommonObject $numref = "(PROV".$this->id.")"; $sql = "UPDATE ".MAIN_DB_PREFIX."livraison "; - $sql.= "SET ref = '".$this->db->escape($numref)."'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= "SET ref = '".$this->db->escape($numref)."'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog("Livraison::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - if (! $conf->expedition_bon->enabled) + if (!$conf->expedition_bon->enabled) { $commande = new Commande($this->db); $commande->id = $this->commande_id; @@ -180,19 +180,19 @@ class Livraison extends CommonObject /* * Inserting products into the database */ - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { - $origin_id=$this->lines[$i]->origin_line_id; - if (! $origin_id) $origin_id=$this->lines[$i]->commande_ligne_id; // For backward compatibility + $origin_id = $this->lines[$i]->origin_line_id; + if (!$origin_id) $origin_id = $this->lines[$i]->commande_ligne_id; // For backward compatibility - if (! $this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description)) + if (!$this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description)) { $error++; } } - if (! $error && $this->id && $this->origin_id) + if (!$error && $this->id && $this->origin_id) { $ret = $this->add_object_linked(); if (!$ret) @@ -200,18 +200,18 @@ class Livraison extends CommonObject $error++; } - if (! $conf->expedition_bon->enabled) + if (!$conf->expedition_bon->enabled) { // TODO uniformiser les statuts $ret = $this->setStatut(2, $this->origin_id, $this->origin); - if (! $ret) + if (!$ret) { $error++; } } } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -219,7 +219,7 @@ class Livraison extends CommonObject else { $error++; - $this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror; + $this->error = $this->db->lasterror()." - sql=".$this->db->lastqueryerror; $this->db->rollback(); return -3; } @@ -227,7 +227,7 @@ class Livraison extends CommonObject else { $error++; - $this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror; + $this->error = $this->db->lasterror()." - sql=".$this->db->lastqueryerror; $this->db->rollback(); return -2; } @@ -235,7 +235,7 @@ class Livraison extends CommonObject else { $error++; - $this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror; + $this->error = $this->db->lasterror()." - sql=".$this->db->lastqueryerror; $this->db->rollback(); return -1; } @@ -259,19 +259,19 @@ class Livraison extends CommonObject $j = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_origin_line,"; - $sql.= " fk_product, description, qty)"; - $sql.= " VALUES (".$this->id.",".$origin_id.","; - $sql.= " ".($idprod>0?$idprod:"null").","; - $sql.= " ".($description?"'".$this->db->escape($description)."'":"null").","; - $sql.= $qty.")"; + $sql .= " fk_product, description, qty)"; + $sql .= " VALUES (".$this->id.",".$origin_id.","; + $sql .= " ".($idprod > 0 ? $idprod : "null").","; + $sql .= " ".($description ? "'".$this->db->escape($description)."'" : "null").","; + $sql .= $qty.")"; dol_syslog(get_class($this)."::create_line", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { $error++; } - if ($error == 0 ) + if ($error == 0) { return 1; } @@ -288,15 +288,15 @@ class Livraison extends CommonObject global $conf; $sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,"; - $sql.=" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public"; - $sql.= ", l.date_delivery, l.fk_address, l.model_pdf"; - $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; - $sql.= ', l.fk_incoterms, l.location_incoterms'; - $sql.= ", i.libelle as label_incoterms"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid'; - $sql.= " WHERE l.rowid = ".$id; + $sql .= " l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public"; + $sql .= ", l.date_delivery, l.fk_address, l.model_pdf"; + $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; + $sql .= ', l.fk_incoterms, l.location_incoterms'; + $sql .= ", i.libelle as label_incoterms"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid'; + $sql .= " WHERE l.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -321,8 +321,8 @@ class Livraison extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; - $this->origin = $obj->origin; // May be 'shipping' - $this->origin_id = $obj->origin_id; // May be id of shipping + $this->origin = $obj->origin; // May be 'shipping' + $this->origin_id = $obj->origin_id; // May be id of shipping //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -337,7 +337,7 @@ class Livraison extends CommonObject $this->fetch_optionals(); // Load lines - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { return -3; @@ -347,14 +347,14 @@ class Livraison extends CommonObject } else { - $this->error='Delivery with id '.$id.' not found sql='.$sql; + $this->error = 'Delivery with id '.$id.' not found sql='.$sql; dol_syslog(get_class($this).'::fetch Error '.$this->error, LOG_ERR); return -2; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -377,19 +377,19 @@ class Livraison extends CommonObject $error = 0; - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->livraison->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->livraison_advance->validate))) { - if (! empty($conf->global->LIVRAISON_ADDON_NUMBER)) + if (!empty($conf->global->LIVRAISON_ADDON_NUMBER)) { // Setting the command numbering module name $modName = $conf->global->LIVRAISON_ADDON_NUMBER; - if (is_readable(DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php')) + if (is_readable(DOL_DOCUMENT_ROOT.'/core/modules/livraison/'.$modName.'.php')) { - require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php'; + require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/'.$modName.'.php'; - $now=dol_now(); + $now = dol_now(); // Retrieving the new reference $objMod = new $modName($this->db); @@ -408,12 +408,12 @@ class Livraison extends CommonObject // Test if is not already in valid status. If so, we stop to avoid decrementing the stock twice. $sql = "SELECT ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE ref = '".$this->db->escape($numref)."'"; - $sql.= " AND fk_statut <> 0"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE ref = '".$this->db->escape($numref)."'"; + $sql .= " AND fk_statut <> 0"; + $sql .= " AND entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -424,30 +424,30 @@ class Livraison extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sql.= " ref='".$this->db->escape($numref)."'"; - $sql.= ", fk_statut = 1"; - $sql.= ", date_valid = '".$this->db->idate($now)."'"; - $sql.= ", fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = 0"; + $sql .= " ref='".$this->db->escape($numref)."'"; + $sql .= ", fk_statut = 1"; + $sql .= ", date_valid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND fk_statut = 0"; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('DELIVERY_VALIDATE', $user); + $result = $this->call_trigger('DELIVERY_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -455,17 +455,17 @@ class Livraison extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/receipt/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/receipt/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expedition/receipt/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/receipt/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->expedition->dir_output.'/receipt/'.$oldref; $dirdest = $conf->expedition->dir_output.'/receipt/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); @@ -473,13 +473,13 @@ class Livraison extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -487,7 +487,7 @@ class Livraison extends CommonObject } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $numref; $this->statut = 1; @@ -496,7 +496,7 @@ class Livraison extends CommonObject dol_syslog(get_class($this)."::valid ok"); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -511,7 +511,7 @@ class Livraison extends CommonObject } else { - $this->error="Non autorise"; + $this->error = "Non autorise"; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -529,11 +529,11 @@ class Livraison extends CommonObject { // phpcs:enable $expedition = new Expedition($this->db); - $result=$expedition->fetch($sending_id); + $result = $expedition->fetch($sending_id); $this->lines = array(); - $num=count($expedition->lines); + $num = count($expedition->lines); for ($i = 0; $i < $num; $i++) { $line = new LivraisonLigne($this->db); @@ -555,10 +555,10 @@ class Livraison extends CommonObject $this->date_delivery = $expedition->date_delivery; $this->fk_delivery_address = $expedition->fk_delivery_address; $this->socid = $expedition->socid; - $this->ref_customer = $expedition->ref_customer; + $this->ref_customer = $expedition->ref_customer; //Incoterms - $this->fk_incoterms = $expedition->fk_incoterms; + $this->fk_incoterms = $expedition->fk_incoterms; $this->location_incoterms = $expedition->location_incoterms; return $this->create($user); @@ -578,21 +578,21 @@ class Livraison extends CommonObject global $conf; $error = 0; - if ($id > 0 && ! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $livraisonline = new LivraisonLigne($this->db); - $livraisonline->array_options=$array_options; - $livraisonline->id=$id; - $result=$livraisonline->insertExtraFields(); + $livraisonline->array_options = $array_options; + $livraisonline->id = $id; + $result = $livraisonline->insertExtraFields(); if ($result < 0) { - $this->error[]=$livraisonline->error; + $this->error[] = $livraisonline->error; $error++; } } - if (! $error) return 1; + if (!$error) return 1; else return -1; } @@ -626,9 +626,9 @@ class Livraison extends CommonObject if ($this->statut == 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; - $sql.= " WHERE rowid = ".$lineid; + $sql .= " WHERE rowid = ".$lineid; - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { $this->update_price(); @@ -653,30 +653,30 @@ class Livraison extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $this->db->begin(); - $error=0; + $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet"; - $sql.= " WHERE fk_livraison = ".$this->id; + $sql .= " WHERE fk_livraison = ".$this->id; if ($this->db->query($sql)) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { $this->db->commit(); // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); - if (! empty($conf->expedition->dir_output)) + if (!empty($conf->expedition->dir_output)) { - $dir = $conf->expedition->dir_output . '/receipt/' . $ref ; - $file = $dir . '/' . $ref . '.pdf'; + $dir = $conf->expedition->dir_output.'/receipt/'.$ref; + $file = $dir.'/'.$ref.'.pdf'; if (file_exists($file)) { if (!dol_delete_file($file)) @@ -688,14 +688,14 @@ class Livraison extends CommonObject { if (!dol_delete_dir($dir)) { - $this->error=$langs->trans("ErrorCanNotDeleteDir", $dir); + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); return 0; } } } // Call trigger - $result=$this->call_trigger('DELIVERY_DELETE', $user); + $result = $this->call_trigger('DELIVERY_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -707,21 +707,21 @@ class Livraison extends CommonObject } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -738,28 +738,28 @@ class Livraison extends CommonObject { global $langs; - $result=''; - $picto='sending'; + $result = ''; + $picto = 'sending'; - $label=$langs->trans("ShowReceiving").': '.$this->ref; + $label = $langs->trans("ShowReceiving").': '.$this->ref; - $url=DOL_URL_ROOT.'/livraison/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/livraison/card.php?id='.$this->id; //if ($option !== 'nolink') //{ // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} $linkstart = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$linkstart.$this->ref.$linkend; + if ($withpicto) $result .= ($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + $result .= $linkstart.$this->ref.$linkend; return $result; } @@ -775,13 +775,13 @@ class Livraison extends CommonObject $this->lines = array(); $sql = "SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, "; - $sql.= " cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,"; - $sql.= " p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,"; - $sql.= " p.weight, p.weight_units, p.width, p.width_units, p.length, p.length_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product"; - $sql.= " WHERE ld.fk_origin_line = cd.rowid"; - $sql.= " AND ld.fk_livraison = ".$this->id; + $sql .= " cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,"; + $sql .= " p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,"; + $sql .= " p.weight, p.weight_units, p.width, p.width_units, p.length, p.length_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product"; + $sql .= " WHERE ld.fk_origin_line = cd.rowid"; + $sql .= " AND ld.fk_livraison = ".$this->id; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -795,23 +795,23 @@ class Livraison extends CommonObject $obj = $this->db->fetch_object($resql); - $line->id = $obj->rowid; - $line->label = $obj->custom_label; + $line->id = $obj->rowid; + $line->label = $obj->custom_label; $line->description = $obj->description; - $line->fk_product = $obj->fk_product; - $line->qty_asked = $obj->qty_asked; + $line->fk_product = $obj->fk_product; + $line->qty_asked = $obj->qty_asked; $line->qty_shipped = $obj->qty_shipped; - $line->ref = $obj->product_ref; // deprecated - $line->libelle = $obj->product_label; // deprecated - $line->product_label = $obj->product_label; // Product label - $line->product_ref = $obj->product_ref; // Product ref - $line->product_desc = $obj->product_desc; // Product description + $line->ref = $obj->product_ref; // deprecated + $line->libelle = $obj->product_label; // deprecated + $line->product_label = $obj->product_label; // Product label + $line->product_ref = $obj->product_ref; // Product ref + $line->product_desc = $obj->product_desc; // Product description $line->product_type = $obj->fk_product_type; - $line->fk_origin_line = $obj->fk_origin_line; + $line->fk_origin_line = $obj->fk_origin_line; - $line->price = $obj->price; - $line->total_ht = $obj->total_ht; + $line->price = $obj->price; + $line->total_ht = $obj->total_ht; // units $line->weight = $obj->weight; @@ -823,11 +823,11 @@ class Livraison extends CommonObject $line->length = $obj->length; $line->length_units = $obj->length_units; $line->surface = $obj->surface; - $line->surface_units = $obj->surface_units; + $line->surface_units = $obj->surface_units; $line->volume = $obj->volume; $line->volume_units = $obj->volume_units; - $line->fk_unit = $obj->fk_unit; + $line->fk_unit = $obj->fk_unit; $this->lines[$i] = $line; @@ -893,17 +893,17 @@ class Livraison extends CommonObject */ public function initAsSpecimen() { - global $user,$langs,$conf; + global $user, $langs, $conf; - $now=dol_now(); + $now = dol_now(); // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; - $sql.= " AND tosell = 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; + $sql .= " AND tosell = 1"; $resql = $this->db->query($sql); if ($resql) { @@ -918,16 +918,16 @@ class Livraison extends CommonObject } // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date_delivery = $now; - $this->note_public='Public note'; - $this->note_private='Private note'; + $this->note_public = 'Public note'; + $this->note_private = 'Private note'; - $i=0; - $line=new LivraisonLigne($this->db); + $i = 0; + $line = new LivraisonLigne($this->db); $line->fk_product = $prodids[0]; $line->qty_asked = 10; $line->qty_shipped = 9; @@ -955,10 +955,10 @@ class Livraison extends CommonObject //var_dump($this->linkedObjectIds); // Get the product ref and qty in source $sqlSourceLine = "SELECT st.rowid, st.description, st.qty"; - $sqlSourceLine.= ", p.ref, p.label"; - $sqlSourceLine.= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st"; - $sqlSourceLine.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; - $sqlSourceLine.= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; + $sqlSourceLine .= ", p.ref, p.label"; + $sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st"; + $sqlSourceLine .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; + $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; $resultSourceLine = $this->db->query($sqlSourceLine); if ($resultSourceLine) @@ -972,15 +972,15 @@ class Livraison extends CommonObject // Get lines of sources alread delivered $sql = "SELECT ld.fk_origin_line, sum(ld.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l,"; - $sql.= " ".MAIN_DB_PREFIX.$this->linked_object[0]['type']." as c"; - $sql.= ", ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as cd"; - $sql.= " WHERE ld.fk_livraison = l.rowid"; - $sql.= " AND ld.fk_origin_line = cd.rowid"; - $sql.= " AND cd.fk_".$this->linked_object[0]['type']." = c.rowid"; - $sql.= " AND cd.fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; - $sql.= " AND ld.fk_origin_line = ".$objSourceLine->rowid; - $sql.= " GROUP BY ld.fk_origin_line"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l,"; + $sql .= " ".MAIN_DB_PREFIX.$this->linked_object[0]['type']." as c"; + $sql .= ", ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as cd"; + $sql .= " WHERE ld.fk_livraison = l.rowid"; + $sql .= " AND ld.fk_origin_line = cd.rowid"; + $sql .= " AND cd.fk_".$this->linked_object[0]['type']." = c.rowid"; + $sql .= " AND cd.fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; + $sql .= " AND ld.fk_origin_line = ".$objSourceLine->rowid; + $sql .= " GROUP BY ld.fk_origin_line"; $result = $this->db->query($sql); $row = $this->db->fetch_row($result); @@ -997,13 +997,13 @@ class Livraison extends CommonObject } $array[$i]['ref'] = $objSourceLine->ref; - $array[$i]['label'] = $objSourceLine->label?$objSourceLine->label:$objSourceLine->description; + $array[$i]['label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description; } - elseif($objSourceLine->qty - $row[1] < 0) + elseif ($objSourceLine->qty - $row[1] < 0) { - $array[$i]['qty'] = $objSourceLine->qty - $row[1]. " Erreur livraison !"; + $array[$i]['qty'] = $objSourceLine->qty - $row[1]." Erreur livraison !"; $array[$i]['ref'] = $objSourceLine->ref; - $array[$i]['label'] = $objSourceLine->label?$objSourceLine->label:$objSourceLine->description; + $array[$i]['label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description; } $i++; @@ -1012,7 +1012,7 @@ class Livraison extends CommonObject } else { - $this->error=$this->db->error()." - sql=$sqlSourceLine"; + $this->error = $this->db->error()." - sql=$sqlSourceLine"; return -1; } } @@ -1031,11 +1031,11 @@ class Livraison extends CommonObject if ($user->rights->expedition->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."livraison"; - $sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->date_delivery = $date_livraison; @@ -1043,7 +1043,7 @@ class Livraison extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1065,16 +1065,16 @@ class Livraison extends CommonObject */ public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$user,$langs; + global $conf, $user, $langs; $langs->load("deliveries"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'typhon'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->LIVRAISON_ADDON_PDF)) { + } elseif (!empty($conf->global->LIVRAISON_ADDON_PDF)) { $modele = $conf->global->LIVRAISON_ADDON_PDF; } } @@ -1149,12 +1149,12 @@ class LivraisonLigne extends CommonObjectLine /** * @var string ID to identify managed object */ - public $element='livraisondet'; + public $element = 'livraisondet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='livraisondet'; + public $table_element = 'livraisondet'; /** * Constructor @@ -1163,6 +1163,6 @@ class LivraisonLigne extends CommonObjectLine */ public function __construct($db) { - $this->db=$db; + $this->db = $db; } } diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 9e7b8f2565a..47ddfd2b109 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -27,29 +27,29 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","loan")); +$langs->loadLangs(array("compta", "bills", "loan")); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -$cancel=GETPOST('cancel', 'alpha'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$cancel = GETPOST('cancel', 'alpha'); $projectid = GETPOST('projectid', 'int'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'loan', $id, '', ''); $object = new Loan($db); -$hookmanager->initHooks(array('loancard','globalcard')); +$hookmanager->initHooks(array('loancard', 'globalcard')); /* diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 8d0cf38af59..3299e810991 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -56,8 +56,8 @@ class LoanSchedule extends CommonObject */ public $datep; - public $amounts=array(); // Array of amounts - public $amount_capital; // Total amount of payment + public $amounts = array(); // Array of amounts + public $amount_capital; // Total amount of payment public $amount_insurance; public $amount_interest; @@ -202,30 +202,30 @@ class LoanSchedule extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.fk_loan,"; - $sql.= " t.datec,"; - $sql.= " t.tms,"; - $sql.= " t.datep,"; - $sql.= " t.amount_capital,"; - $sql.= " t.amount_insurance,"; - $sql.= " t.amount_interest,"; - $sql.= " t.fk_typepayment,"; - $sql.= " t.num_payment,"; - $sql.= " t.note_private,"; - $sql.= " t.note_public,"; - $sql.= " t.fk_bank,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_label,"; - $sql.= ' b.fk_account'; - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.fk_loan,"; + $sql .= " t.datec,"; + $sql .= " t.tms,"; + $sql .= " t.datep,"; + $sql .= " t.amount_capital,"; + $sql .= " t.amount_insurance,"; + $sql .= " t.amount_interest,"; + $sql .= " t.fk_typepayment,"; + $sql .= " t.num_payment,"; + $sql .= " t.note_private,"; + $sql .= " t.note_public,"; + $sql .= " t.fk_bank,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_modif,"; + $sql .= " pt.code as type_code, pt.libelle as type_label,"; + $sql .= ' b.fk_account'; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); @@ -276,16 +276,16 @@ class LoanSchedule extends CommonObject public function update($user = 0, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital); - if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance); - if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest); - if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); - if (isset($this->note_private)) $this->note_private=trim($this->note_private); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital); + if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance); + if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest); + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank); // Check parameters // Put here code to add control on parameters values @@ -533,7 +533,7 @@ class LoanSchedule extends CommonObject public function paimenttorecord($loanid, $datemax) { - $result=array(); + $result = array(); $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 1bd0f874949..485d48dc443 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -197,30 +197,30 @@ class PaymentLoan extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.fk_loan,"; - $sql.= " t.datec,"; - $sql.= " t.tms,"; - $sql.= " t.datep,"; - $sql.= " t.amount_capital,"; - $sql.= " t.amount_insurance,"; - $sql.= " t.amount_interest,"; - $sql.= " t.fk_typepayment,"; - $sql.= " t.num_payment,"; - $sql.= " t.note_private,"; - $sql.= " t.note_public,"; - $sql.= " t.fk_bank,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_label,"; - $sql.= ' b.fk_account'; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.fk_loan,"; + $sql .= " t.datec,"; + $sql .= " t.tms,"; + $sql .= " t.datep,"; + $sql .= " t.amount_capital,"; + $sql .= " t.amount_insurance,"; + $sql .= " t.amount_interest,"; + $sql .= " t.fk_typepayment,"; + $sql .= " t.num_payment,"; + $sql .= " t.note_private,"; + $sql .= " t.note_public,"; + $sql .= " t.fk_bank,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_modif,"; + $sql .= " pt.code as type_code, pt.libelle as type_label,"; + $sql .= ' b.fk_account'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -515,16 +515,16 @@ class PaymentLoan extends CommonObject { global $langs; - $result=''; + $result = ''; if (!empty($this->id)) { $link = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref, 'payment').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + if ($withpicto) $result .= ($link.img_object($langs->trans("ShowPayment").': '.$this->ref, 'payment').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; } return $result; diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 28b4d55ce17..a68ec64f7b1 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -28,19 +28,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("other","companies","compta","bills","loan")); +$langs->loadLangs(array("other", "companies", "compta", "bills", "loan")); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'loan', $id, '', ''); // Get parameters diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 575c8d74586..21661d787f5 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -26,19 +26,19 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("compta","bills","loan")); +$langs->loadLangs(array("compta", "bills", "loan")); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'loan', $id, '', ''); diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index f2a3aa3a877..4798366d087 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -24,24 +24,24 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; -if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","banks","companies","loan")); +$langs->loadLangs(array("bills", "banks", "companies", "loan")); // Security check -$id=GETPOST("id", 'int'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST("id", 'int'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +if ($user->socid) $socid = $user->socid; // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); $payment = new PaymentLoan($db); if ($id > 0) { - $result=$payment->fetch($id); - if (! $result) dol_print_error($db, 'Failed to get payment id '.$id); + $result = $payment->fetch($id); + if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); } @@ -76,20 +76,20 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->wri { $db->begin(); - $result=$payment->valide(); + $result = $payment->valide(); if ($result > 0) { $db->commit(); - $factures=array(); // TODO Get all id of invoices linked to this payment - foreach($factures as $id) + $factures = array(); // TODO Get all id of invoices linked to this payment + foreach ($factures as $id) { $fac = new Facture($db); $fac->fetch($id); $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) + if (!empty($_REQUEST['lang_id'])) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); @@ -119,7 +119,7 @@ llxHeader(); $loan = new Loan($db); $form = new Form($db); -$h=0; +$h = 0; $head[$h][0] = DOL_URL_ROOT.'/loan/payment/card.php?id='.$id; $head[$h][1] = $langs->trans("Card"); @@ -172,11 +172,11 @@ print ''; // Bank account -if (! empty($conf->banque->enabled)) +if (!empty($conf->banque->enabled)) { if ($payment->bank_account) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($payment->bank_line); print ''; @@ -197,13 +197,13 @@ print '
      '; print $langs->trans("ServerConnection")." : $dolibarr_main_db_host".$langs->trans("OK")."
      ".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->transnoentities("Error")."
      '; print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."".$langs->trans("OK")."
      ".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->trans("Error")."
      '.$langs->trans("ServerVersion").''.$version.'
      '.$langs->trans("ClientCharset").''.$tmparray->charset.'
      '.$langs->trans("ClientSortingCharset").''.$tmparray->collation.'
      ".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))."".$langs->trans("Error")."
      '.$langs->trans("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)."
      ".$langs->trans("Error")."
      '.$sqldrop.";
      '.$langs->trans("ChoosedMigrateScript").''.$file.'
      '.$langs->trans("ChoosedMigrateScript").' (external modules)'.$modulefileshort.'
      '.$langs->trans('NotePrivate').''.nl2br($payment->note_p print '
      '.$langs->trans('NotePublic').''.nl2br($payment->note_public).'
      '; $disable_delete = 0; $sql = 'SELECT l.rowid as id, l.label, l.paid, l.capital as capital, pl.amount_capital, pl.amount_insurance, pl.amount_interest'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl,'.MAIN_DB_PREFIX.'loan as l'; -$sql.= ' WHERE pl.fk_loan = l.rowid'; -$sql.= ' AND l.entity = '.$conf->entity; -$sql.= ' AND pl.rowid = '.$payment->id; +$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl,'.MAIN_DB_PREFIX.'loan as l'; +$sql .= ' WHERE pl.fk_loan = l.rowid'; +$sql .= ' AND l.entity = '.$conf->entity; +$sql .= ' AND pl.rowid = '.$payment->id; dol_syslog("loan/payment/card.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -281,9 +281,9 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) } */ -if (empty($action) && ! empty($user->rights->loan->delete)) +if (empty($action) && !empty($user->rights->loan->delete)) { - if (! $disable_delete) + if (!$disable_delete) { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index a6ca3c768d6..ea37a298d49 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -28,16 +28,16 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->loadLangs(array("bills","loan")); +$langs->loadLangs(array("bills", "loan")); -$chid=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$chid = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); $line_id = GETPOST('line_id', 'int'); -$last=GETPOST('last'); +$last = GETPOST('last'); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) { $socid = $user->socid; @@ -46,7 +46,7 @@ if ($user->socid > 0) $loan = new Loan($db); $loan->fetch($chid); -if($last) +if ($last) { $ls = new LoanSchedule($db); // grab all loanschedule @@ -69,7 +69,7 @@ if (!empty($line_id)) { $line = new LoanSchedule($db); $res = $line->fetch($line_id); - if ($res > 0){ + if ($res > 0) { $amount_capital = price($line->amount_capital); $amount_insurance = price($line->amount_insurance); $amount_interest = price($line->amount_interest); @@ -83,7 +83,7 @@ if (!empty($line_id)) if ($action == 'add_payment') { - $error=0; + $error = 0; if ($cancel) { @@ -94,7 +94,7 @@ if ($action == 'add_payment') $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (! GETPOST('paymenttype', 'int') > 0) + if (!GETPOST('paymenttype', 'int') > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; @@ -104,13 +104,13 @@ if ($action == 'add_payment') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled) && ! GETPOST('accountid', 'int') > 0) + if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $paymentid = 0; @@ -121,24 +121,24 @@ if ($action == 'add_payment') $error++; } - if (! $error) + if (!$error) { $db->begin(); // Create a line of payments $payment = new PaymentLoan($db); - $payment->chid = $chid; + $payment->chid = $chid; $payment->datep = $datepaid; - $payment->label = $loan->label; - $payment->amount_capital = GETPOST('amount_capital'); - $payment->amount_insurance = GETPOST('amount_insurance'); - $payment->amount_interest = GETPOST('amount_interest'); + $payment->label = $loan->label; + $payment->amount_capital = GETPOST('amount_capital'); + $payment->amount_insurance = GETPOST('amount_insurance'); + $payment->amount_interest = GETPOST('amount_interest'); $payment->paymenttype = GETPOST('paymenttype', 'int'); - $payment->num_payment = GETPOST('num_payment'); + $payment->num_payment = GETPOST('num_payment'); $payment->note_private = GETPOST('note_private', 'none'); $payment->note_public = GETPOST('note_public', 'none'); - if (! $error) + if (!$error) { $paymentid = $payment->create($user); if ($paymentid < 0) @@ -148,22 +148,22 @@ if ($action == 'add_payment') } } - if (! $error) + if (!$error) { $result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', GETPOST('accountid', 'int'), '', ''); - if (! $result > 0) + if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } - elseif(isset($line)) + elseif (isset($line)) { $line->fk_bank = $payment->fk_bank; $line->update($user); } } - if (! $error) + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid; @@ -187,7 +187,7 @@ if ($action == 'add_payment') llxHeader(); -$form=new Form($db); +$form = new Form($db); // Form to create loan's payment @@ -216,17 +216,17 @@ if ($action == 'create') print '
      '.$langs->trans("Amount").''.price($loan->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
      '.$langs->trans("AlreadyPaid").''.price($sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).'
      '.$langs->trans("RemainderToPay").''.price($total-$sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).'
      '.$langs->trans("RemainderToPay").''.price($total - $sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).'
      '; @@ -240,20 +240,20 @@ if ($action == 'create') print '
      '.$langs->trans("Date").''; $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); print "
      '.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$loan->paymenttype, "paymenttype"); + $form->select_types_paiements(isset($_POST["paymenttype"]) ? $_POST["paymenttype"] : $loan->paymenttype, "paymenttype"); print "
      '.$langs->trans('AccountToDebit').''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$loan->accountid, "accountid", 0, '', 1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $loan->accountid, "accountid", 0, '', 1); // Show opend bank account list print '
      '; if ($sumpaid < $loan->capital) { - print $langs->trans("LoanCapital") .': '; + print $langs->trans("LoanCapital").': '; } else { @@ -314,7 +314,7 @@ if ($action == 'create') print '
      '; if ($sumpaid < $loan->capital) { - print $langs->trans("Insurance") .': '; + print $langs->trans("Insurance").': '; } else { @@ -323,7 +323,7 @@ if ($action == 'create') print '
      '; if ($sumpaid < $loan->capital) { - print $langs->trans("Interest") .': '; + print $langs->trans("Interest").': '; } else { diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index d8b5c7ed36e..41a221a7e72 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -47,7 +47,7 @@ class MailmanSpip /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Array of error strings @@ -156,8 +156,8 @@ class MailmanSpip curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?5:$conf->global->MAIN_USE_CONNECT_TIMEOUT); - curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); @@ -197,8 +197,8 @@ class MailmanSpip if ($mydb) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $mdpass=dol_hash($object->pass); - $htpass=crypt($object->pass, makesalt()); + $mdpass = dol_hash($object->pass); + $htpass = crypt($object->pass, makesalt()); $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".dolGetFirstLastname($object->firstname, $object->lastname)."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; $result = $mydb->query($query); @@ -324,42 +324,42 @@ class MailmanSpip public function add_to_mailman($object, $listes = '') { // phpcs:enable - global $conf,$langs,$user; + global $conf, $langs, $user; dol_syslog(get_class($this)."::add_to_mailman"); - $this->mladded_ok=array(); - $this->mladded_ko=array(); + $this->mladded_ok = array(); + $this->mladded_ko = array(); - if (! function_exists("curl_init")) + if (!function_exists("curl_init")) { $langs->load("errors"); - $this->error=$langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init"); + $this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init"); return -1; } if ($conf->adherent->enabled) // Synchro for members { - if (! empty($conf->global->ADHERENT_MAILMAN_URL)) + if (!empty($conf->global->ADHERENT_MAILMAN_URL)) { - if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists=explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); - else $lists=explode(',', $listes); + if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); + else $lists = explode(',', $listes); - $categstatic=new Categorie($this->db); + $categstatic = new Categorie($this->db); foreach ($lists as $list) { // Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2") - $tmp=explode(':', $list); - if (! empty($tmp[2])) + $tmp = explode(':', $list); + if (!empty($tmp[2])) { - $list=$tmp[2]; + $list = $tmp[2]; if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label { dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG); continue; } - if ($object->element == 'member' && $tmp[0] == 'CATEG' && ! in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category + if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category { dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG); continue; @@ -371,16 +371,16 @@ class MailmanSpip if ($result === false) { - $this->mladded_ko[$list]=$object->email; + $this->mladded_ko[$list] = $object->email; return -2; } - else $this->mladded_ok[$list]=$object->email; + else $this->mladded_ok[$list] = $object->email; } return count($lists); } else { - $this->error="ADHERENT_MAILMAN_URL not defined"; + $this->error = "ADHERENT_MAILMAN_URL not defined"; return -1; } } @@ -398,42 +398,42 @@ class MailmanSpip public function del_to_mailman($object, $listes = '') { // phpcs:enable - global $conf,$langs,$user; + global $conf, $langs, $user; dol_syslog(get_class($this)."::del_to_mailman"); - $this->mlremoved_ok=array(); - $this->mlremoved_ko=array(); + $this->mlremoved_ok = array(); + $this->mlremoved_ko = array(); - if (! function_exists("curl_init")) + if (!function_exists("curl_init")) { $langs->load("errors"); - $this->error=$langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init"); + $this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init"); return -1; } if ($conf->adherent->enabled) // Synchro for members { - if (! empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) + if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) { - if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists=explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); - else $lists=explode(',', $listes); + if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); + else $lists = explode(',', $listes); - $categstatic=new Categorie($this->db); + $categstatic = new Categorie($this->db); foreach ($lists as $list) { // Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2") - $tmp=explode(':', $list); - if (! empty($tmp[2])) + $tmp = explode(':', $list); + if (!empty($tmp[2])) { - $list=$tmp[2]; + $list = $tmp[2]; if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label { dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG); continue; } - if ($object->element == 'member' && $tmp[0] == 'CATEG' && ! in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category + if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category { dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG); continue; @@ -445,16 +445,16 @@ class MailmanSpip if ($result === false) { - $this->mlremoved_ko[$list]=$object->email; + $this->mlremoved_ko[$list] = $object->email; return -2; } - else $this->mlremoved_ok[$list]=$object->email; + else $this->mlremoved_ok[$list] = $object->email; } return count($lists); } else { - $this->error="ADHERENT_MAILMAN_UNSUB_URL not defined"; + $this->error = "ADHERENT_MAILMAN_UNSUB_URL not defined"; return -1; } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f17579e9d78..965d49de2f7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -232,7 +232,7 @@ require_once 'master.inc.php'; register_shutdown_function('dol_shutdown'); // Load debugbar -if (!empty($conf->debugbar->enabled) && ! GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) +if (!empty($conf->debugbar->enabled) && !GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) { global $debugbar; include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; @@ -283,7 +283,7 @@ if (!empty($conf->file->main_force_https) && (empty($_SERVER["HTTPS"]) || $_SERV // Start redirect if ($newurl) { - header_remove(); // Clean header already set to be sure to remove any header like "Set-Cookie: DOLSESSID_..." from non HTTPS answers + header_remove(); // Clean header already set to be sure to remove any header like "Set-Cookie: DOLSESSID_..." from non HTTPS answers dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl); header("Location: ".$newurl); exit; @@ -1706,7 +1706,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Logout link $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem logout-btn', 2); - $toprightmenu .= ''; // end div class="login_block_other" + $toprightmenu .= ''; // end div class="login_block_other" // Add login user link @@ -2591,14 +2591,14 @@ if (!function_exists("llxFooter")) || $forceping) { // No ping done if we are into an alpha version - if (strpos('alpha', DOL_VERSION) > 0 && ! $forceping) { + if (strpos('alpha', DOL_VERSION) > 0 && !$forceping) { print "\n\n"; } elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) // Cookie is set when we uncheck the checkbox in the installation wizard. { // MAIN_LAST_PING_KO_DATE // Disable ping if MAIN_LAST_PING_KO_DATE is set and is recent - if (! empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) == dol_print_date(dol_now(), '%Y%m') && ! $forceping) { + if (!empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) == dol_print_date(dol_now(), '%Y%m') && !$forceping) { print "\n\n"; } else { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -2609,7 +2609,7 @@ if (!function_exists("llxFooter")) // Try to guess the distrib used $distrib = 'standard'; if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; - if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; + if (!empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; ?> @@ -48,8 +48,8 @@ if (empty($usedolheader)) } else { - $arraycss=array(); - $arrayjs=array(); + $arraycss = array(); + $arrayjs = array(); /* $arraycss=array('/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css', '/includes/jquery/plugins/datatables/extensions/Buttons/css/buttons.dataTables.min.css', @@ -153,71 +153,71 @@ $(document).ready(function() { initAsSpecimen(); -$sortfield='aaa'; -$sortorder='ASC'; -$tasksarray=array(1,2,3); // To force having several lines -$tagidfortablednd='tablelines3'; -if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; +$sortfield = 'aaa'; +$sortorder = 'ASC'; +$tasksarray = array(1, 2, 3); // To force having several lines +$tagidfortablednd = 'tablelines3'; +if (!empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; -$nav=''; -$nav.=''; -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav.=''; -if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.=''; -if ($filter) $nav.=''; -if ($filtert) $nav.=''; -if ($socid) $nav.=''; -if ($showbirthday) $nav.=''; -if ($pid) $nav.=''; -if ($type) $nav.=''; -if ($usergroup) $nav.=''; -$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav.= ' '; -$nav.= ''; +$nav = ''; +$nav .= '
      '; +if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav .= ''; +if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav .= ''; +if ($filter) $nav .= ''; +if ($filtert) $nav .= ''; +if ($socid) $nav .= ''; +if ($showbirthday) $nav .= ''; +if ($pid) $nav .= ''; +if ($type) $nav .= ''; +if ($usergroup) $nav .= ''; +$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); +$nav .= ' '; +$nav .= '
      '; -$limit=10; +$limit = 10; print_barre_liste('Title of my list', 12, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 500, '', 0, $nav, '', $limit); -$moreforfilter.='
      '; -$moreforfilter.=$langs->trans('This is a select list for a filter A'). ': '; -$cate_arbo = array('field1'=>'value1a into the select list A','field2'=>'value2a'); -$moreforfilter.=$form->selectarray('search_aaa', $cate_arbo, '', 1); // List without js combo -$moreforfilter.='
      '; +$moreforfilter .= '
      '; +$moreforfilter .= $langs->trans('This is a select list for a filter A').': '; +$cate_arbo = array('field1'=>'value1a into the select list A', 'field2'=>'value2a'); +$moreforfilter .= $form->selectarray('search_aaa', $cate_arbo, '', 1); // List without js combo +$moreforfilter .= '
      '; -$moreforfilter.='
      '; -$moreforfilter.=$langs->trans('This is a select list for a filter B'). ': '; -$cate_arbo = array('field1'=>'value1b into the select list B','field2'=>'value2b'); -$moreforfilter.=$form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo -$moreforfilter.='
      '; +$moreforfilter .= '
      '; +$moreforfilter .= $langs->trans('This is a select list for a filter B').': '; +$cate_arbo = array('field1'=>'value1b into the select list B', 'field2'=>'value2b'); +$moreforfilter .= $form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo +$moreforfilter .= '
      '; -$moreforfilter.='
      '; -$moreforfilter.=$langs->trans('This is a select list for a filter C'). ': '; -$cate_arbo = array('field1'=>'value1c into the select list C','field2'=>'value2c'); -$moreforfilter.=$form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo -$moreforfilter.='
      '; +$moreforfilter .= '
      '; +$moreforfilter .= $langs->trans('This is a select list for a filter C').': '; +$cate_arbo = array('field1'=>'value1c into the select list C', 'field2'=>'value2c'); +$moreforfilter .= $form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo +$moreforfilter .= '
      '; -$moreforfilter.='
      '; -$moreforfilter.=$langs->trans('This is a select list for a filter D'). ': '; -$cate_arbo = array('field1'=>'value1d into the select list D','field2'=>'value2d'); -$moreforfilter.=$form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo -$moreforfilter.='
      '; +$moreforfilter .= '
      '; +$moreforfilter .= $langs->trans('This is a select list for a filter D').': '; +$cate_arbo = array('field1'=>'value1d into the select list D', 'field2'=>'value2d'); +$moreforfilter .= $form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo +$moreforfilter .= '
      '; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
      '; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
      '; } ?> -" id="tablelines3"> +
      " id="tablelines3"> trans('title1'), 0, $_SERVER["PHP_SELF"], 'aaa', '', '', 'align="left"', $sortfield, $sortorder); ?> @@ -245,7 +245,7 @@ if (! empty($moreforfilter)) $(document).ready(function(){ $('#idtableexample2').dataTable( { use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + $tasksarray = array(1, 2, 3); // To force having several lines + $tagidfortablednd = 'tablelines'; + if (!empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; ?>
      @@ -340,7 +340,7 @@ $(document).ready(function(){ diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index b2f55e1b748..0a43cfda708 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -1,6 +1,6 @@ '; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
      '; // You can use div-table-responsive-no-min if you dont need reserved height for your table // Test1: form->selectDate using tzuser date print "Test 1a: We must have here current date and hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; -$offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; -$offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; +$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; +$offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; print " (dol_tz=".$offsettz." dol_dst=".$dol_dst.")
      \n"; print $form->selectDate(dol_now(), 'test1a', 1, 1, 0); @@ -56,23 +56,23 @@ print '

      '."\n"; // Test4a: a select print "Test 4a: a select
      \n"; -$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3 ith a very long text. aze eazeae e ae aeae a e a ea ea ea e a e aea e ae aeaeaeaze.'); -$selected=3; +$array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3 ith a very long text. aze eazeae e ae aeae a e a ea ea ea e a e aea e ae aeaeaeaze.'); +$selected = 3; print $form->selectarray('testselecta', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1); print '

      '; print "Test 4b: a select
      \n"; -$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3'); -$selected=3; +$array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3'); +$selected = 3; print $form->selectarray('testselectb', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1); print '

      '."\n"; print "Test 4c: Select array with addjscombo not forced
      \n"; -$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3'); +$array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3'); print $form->selectarray('selectarray', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 0); print '

      '."\n"; print "Test 4d: a select with ajax refresh and with onchange call of url
      \n"; -$selected=-1; +$selected = -1; print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth100', 1); print '

      '."\n"; @@ -91,8 +91,8 @@ print '

      '."\n"; // Test5c: a multiselect print "Test 5c: a multiselect
      \n"; -$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3'); -$arrayselected=array(1,3); +$array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3'); +$arrayselected = array(1, 3); print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, 'minwidth100'); print '
      '; diff --git a/htdocs/public/test/test_sessionlock.php b/htdocs/public/test/test_sessionlock.php index ef886d0e789..b10d1e892ec 100644 --- a/htdocs/public/test/test_sessionlock.php +++ b/htdocs/public/test/test_sessionlock.php @@ -1,22 +1,22 @@ trans('YourTicketSuccessfullySaved'), null, 'mesgs'); // Make a redirect to avoid to have ticket submitted twice if we make back - setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', ''.$object->track_id.'', '' . $object->ref . ''), null, 'warnings'); + setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', ''.$object->track_id.'', ''.$object->ref.''), null, 'warnings'); setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); header("Location: index.php"); exit; diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index bbe831c1a84..37fdf9be219 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -24,13 +24,13 @@ if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -68,11 +68,11 @@ $arrayofcss = array('/ticket/css/styles.css.php'); llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); print '
      '; -print '

      ' . ($conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans("TicketPublicDesc")) . '

      '; +print '

      '.($conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans("TicketPublicDesc")).'

      '; print ''; print '
      '; diff --git a/htdocs/public/website/index.php b/htdocs/public/website/index.php index 3b37a164fc8..95f2efa492a 100644 --- a/htdocs/public/website/index.php +++ b/htdocs/public/website/index.php @@ -30,12 +30,12 @@ * \brief Wrapper to output pages when website is powered by Dolibarr instead of a native web server */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOLOGIN')) define("NOLOGIN", 1); -if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOLOGIN')) define("NOLOGIN", 1); +if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); /** * Header empty @@ -58,13 +58,13 @@ require '../../master.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$error=0; -$websitekey=GETPOST('website', 'alpha'); -$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); -$pageref=GETPOST('pageref', 'alphanohtml')?GETPOST('pageref', 'alphanohtml'):''; +$error = 0; +$websitekey = GETPOST('website', 'alpha'); +$pageid = GETPOST('page', 'alpha') ?GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha'); +$pageref = GETPOST('pageref', 'alphanohtml') ?GETPOST('pageref', 'alphanohtml') : ''; $accessallowed = 1; -$type=''; +$type = ''; if (empty($pageid)) @@ -72,7 +72,7 @@ if (empty($pageid)) require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; - $object=new Website($db); + $object = new Website($db); $object->fetch(0, $websitekey); if (empty($object->id)) @@ -87,19 +87,19 @@ if (empty($pageid)) } } - $objectpage=new WebsitePage($db); + $objectpage = new WebsitePage($db); if ($pageref) { - $result=$objectpage->fetch(0, $object->id, $pageref); + $result = $objectpage->fetch(0, $object->id, $pageref); if ($result > 0) { $pageid = $objectpage->id; } - elseif($result == 0) + elseif ($result == 0) { // Page not found from ref=pageurl, we try using alternative alias - $result=$objectpage->fetch(0, $object->id, null, $pageref); + $result = $objectpage->fetch(0, $object->id, null, $pageref); if ($result > 0) { $pageid = $objectpage->id; @@ -110,7 +110,7 @@ if (empty($pageid)) { if ($object->fk_default_home > 0) { - $result=$objectpage->fetch($object->fk_default_home); + $result = $objectpage->fetch($object->fk_default_home); if ($result > 0) { $pageid = $objectpage->id; @@ -119,11 +119,11 @@ if (empty($pageid)) if (empty($pageid)) { - $array=$objectpage->fetchAll($object->id); // TODO Can filter on container of type pages only ? + $array = $objectpage->fetchAll($object->id); // TODO Can filter on container of type pages only ? if (is_array($array) && count($array) > 0) { - $firstrep=reset($array); - $pageid=$firstrep->id; + $firstrep = reset($array); + $pageid = $firstrep->id; } } } @@ -135,14 +135,14 @@ if (empty($pageid)) $langs->load("website"); - if (! GETPOSTISSET('pageref')) print $langs->trans("PreviewOfSiteNotYetAvailable", $websitekey); + if (!GETPOSTISSET('pageref')) print $langs->trans("PreviewOfSiteNotYetAvailable", $websitekey); include DOL_DOCUMENT_ROOT.'/public/error-404.php'; exit; } -$appli=constant('DOL_APPLICATION_TITLE'); -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; +$appli = constant('DOL_APPLICATION_TITLE'); +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE; @@ -163,19 +163,19 @@ if ($pageid == 'css') // No more used ? //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); //else header('Cache-Control: no-cache'); - $original_file=$dolibarr_main_data_root.'/website/'.$websitekey.'/styles.css.php'; + $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/styles.css.php'; } else { - $original_file=$dolibarr_main_data_root.'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; + $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; } // Find the subdirectory name as the reference -$refname=basename(dirname($original_file)."/"); +$refname = basename(dirname($original_file)."/"); // Security: // Limite acces si droits non corrects -if (! $accessallowed) +if (!$accessallowed) { accessforbidden(); } @@ -186,7 +186,7 @@ if (! $accessallowed) if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { dol_syslog("Refused to deliver file ".$original_file); - $file=basename($original_file); // Do no show plain path of original_file in shown error message + $file = basename($original_file); // Do no show plain path of original_file in shown error message dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $file)); exit; } @@ -197,10 +197,10 @@ $filename = basename($original_file); // Output file on browser dol_syslog("index.php include $original_file $filename content-type=$type"); -$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset +$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset // This test if file exists should be useless. We keep it to find bug more easily -if (! file_exists($original_file_osencoded)) +if (!file_exists($original_file_osencoded)) { // Return header 404 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); @@ -216,6 +216,6 @@ if (! file_exists($original_file_osencoded)) // Output page content define('USEDOLIBARRSERVER', 1); print ''."\n"; -include_once $original_file_osencoded; // Note: The pageXXX.tpl.php showed here contains a formatage with dolWebsiteOutput() at end of page. +include_once $original_file_osencoded; // Note: The pageXXX.tpl.php showed here contains a formatage with dolWebsiteOutput() at end of page. if (is_object($db)) $db->close(); diff --git a/htdocs/public/website/styles.css.php b/htdocs/public/website/styles.css.php index e8e4e9a8378..ce416bdd7b6 100644 --- a/htdocs/public/website/styles.css.php +++ b/htdocs/public/website/styles.css.php @@ -21,12 +21,12 @@ * \brief Page to output style page. Called with */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOLOGIN')) define("NOLOGIN", 1); -if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOLOGIN')) define("NOLOGIN", 1); +if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); /** * Header empty @@ -49,21 +49,21 @@ require '../../master.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$error=0; -$website=GETPOST('website', 'alpha'); -$websiteid=GETPOST('websiteid', 'int'); -$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); +$error = 0; +$website = GETPOST('website', 'alpha'); +$websiteid = GETPOST('websiteid', 'int'); +$pageid = GETPOST('page', 'alpha') ?GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha'); $accessallowed = 1; -$type=''; +$type = ''; /* * View */ -$appli=constant('DOL_APPLICATION_TITLE'); -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; +$appli = constant('DOL_APPLICATION_TITLE'); +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE; //print 'Directory with '.$appli.' websites.
      '; @@ -72,18 +72,18 @@ if (empty($pageid)) require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; - $object=new Website($db); + $object = new Website($db); if ($websiteid) { $object->fetch($websiteid); - $website=$object->ref; + $website = $object->ref; } else { $object->fetch(0, $website); } - $objectpage=new WebsitePage($db); + $objectpage = new WebsitePage($db); /* Not required for CSS file $array=$objectpage->fetchAll($object->id); @@ -106,14 +106,14 @@ if (empty($pageid)) // Security: Delete string ../ into $original_file global $dolibarr_main_data_root; -$original_file=$dolibarr_main_data_root.'/website/'.$website.'/styles.css.php'; +$original_file = $dolibarr_main_data_root.'/website/'.$website.'/styles.css.php'; // Find the subdirectory name as the reference -$refname=basename(dirname($original_file)."/"); +$refname = basename(dirname($original_file)."/"); // Security: // Limite acces si droits non corrects -if (! $accessallowed) +if (!$accessallowed) { accessforbidden(); } @@ -124,7 +124,7 @@ if (! $accessallowed) if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { dol_syslog("Refused to deliver file ".$original_file); - $file=basename($original_file); // Do no show plain path of original_file in shown error message + $file = basename($original_file); // Do no show plain path of original_file in shown error message dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $file)); exit; } @@ -135,10 +135,10 @@ $filename = basename($original_file); // Output file on browser dol_syslog("styles.css.php include $original_file $filename content-type=$type"); -$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset +$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset // This test if file exists should be useless. We keep it to find bug more easily -if (! file_exists($original_file_osencoded)) +if (!file_exists($original_file_osencoded)) { $langs->load("website"); print $langs->trans("RequestedPageHasNoContentYet", $pageid); diff --git a/htdocs/reception/class/receptionstats.class.php b/htdocs/reception/class/receptionstats.class.php index 476e32898d9..d55bfeee8eb 100644 --- a/htdocs/reception/class/receptionstats.class.php +++ b/htdocs/reception/class/receptionstats.class.php @@ -24,9 +24,9 @@ * \brief File of class fo tmanage reception statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/reception/class/reception.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -62,20 +62,20 @@ class ReceptionStats extends Stats $this->userid = $userid; $this->cachefilesuffix = $mode; - $object=new Reception($this->db); + $object = new Reception($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; - $this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE - $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled + $this->field = 'weight'; // Warning, unit of weight is NOT USED AND MUST BE + $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $this->where .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { - $this->where.=" AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; } /** @@ -89,16 +89,16 @@ class ReceptionStats extends Stats global $user; $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql); + $res = $this->_getNbByMonth($year, $sql); return $res; } @@ -113,11 +113,11 @@ class ReceptionStats extends Stats global $user; $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -132,11 +132,11 @@ class ReceptionStats extends Stats global $user; $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index c4e4710fde7..7dd0bec2b38 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -39,16 +39,16 @@ $langs->load("orders"); $langs->load("receptions"); $langs->load("companies"); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'reception', $id, ''); $object = new Reception($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index b10c2ffe295..c615017ad37 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -40,11 +40,11 @@ $langs->loadLangs(array("orders", "receptions")); * View */ -$orderstatic=new CommandeFournisseur($db); -$companystatic=new Societe($db); -$reception=new Reception($db); +$orderstatic = new CommandeFournisseur($db); +$companystatic = new Societe($db); +$reception = new Reception($db); -$helpurl='EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; +$helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; llxHeader('', $langs->trans("Reception"), $helpurl); print load_fiche_titre($langs->trans("ReceptionsArea")); @@ -53,7 +53,7 @@ print load_fiche_titre($langs->trans("ReceptionsArea")); print '
      '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { print '
      '; print ''; @@ -73,23 +73,23 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $clause = " WHERE "; $sql = "SELECT e.rowid, e.ref, e.ref_supplier,"; -$sql.= " s.nom as name, s.rowid as socid,"; -$sql.= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id"; -$sql.= " FROM ".MAIN_DB_PREFIX."reception as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +$sql .= " s.nom as name, s.rowid as socid,"; +$sql .= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id"; +$sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql.= $clause." sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= $clause." sc.fk_user = ".$user->id; $clause = " AND "; } -$sql.= $clause." e.fk_statut = 0"; -$sql.= " AND e.entity IN (".getEntity('reception').")"; -if ($socid) $sql.= " AND c.fk_soc = ".$socid; +$sql .= $clause." e.fk_statut = 0"; +$sql .= " AND e.entity IN (".getEntity('reception').")"; +if ($socid) $sql .= " AND c.fk_soc = ".$socid; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
      '; @@ -105,9 +105,9 @@ if ($resql) { $obj = $db->fetch_object($resql); - $reception->id=$obj->rowid; - $reception->ref=$obj->ref; - $reception->ref_supplier=$obj->ref_supplier; + $reception->id = $obj->rowid; + $reception->ref = $obj->ref; + $reception->ref_supplier = $obj->ref_supplier; print '
      '; print ''; // Year print ''; @@ -252,11 +252,11 @@ print ''; print '';*/ print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while (! empty($year) && $oldyear > $year+1) + while (!empty($year) && $oldyear > $year + 1) { // If we have empty year $oldyear--; @@ -279,7 +279,7 @@ foreach ($data as $val) /*print ''; print '';*/ print ''; - $oldyear=$year; + $oldyear = $year; } print '
      '; print $reception->getNomUrl(1); @@ -139,19 +139,19 @@ $max = 5; */ $sql = "SELECT e.rowid, e.ref, e.ref_supplier,"; -$sql.= " s.nom as name, s.rowid as socid,"; -$sql.= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id"; -$sql.= " FROM ".MAIN_DB_PREFIX."reception as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('order_supplier')"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('order_supplier') AND el.targettype = 'reception'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; -$sql.= " WHERE e.entity IN (".getEntity('reception').")"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id; -$sql.= " AND e.fk_statut = 1"; -if ($socid) $sql.= " AND c.fk_soc = ".$socid; -$sql.= " ORDER BY e.date_delivery DESC"; -$sql.= $db->plimit($max, 0); +$sql .= " s.nom as name, s.rowid as socid,"; +$sql .= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id"; +$sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('order_supplier')"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('order_supplier') AND el.targettype = 'reception'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; +$sql .= " WHERE e.entity IN (".getEntity('reception').")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; +$sql .= " AND e.fk_statut = 1"; +if ($socid) $sql .= " AND c.fk_soc = ".$socid; +$sql .= " ORDER BY e.date_delivery DESC"; +$sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) @@ -168,9 +168,9 @@ if ($resql) { $obj = $db->fetch_object($resql); - $reception->id=$obj->rowid; - $reception->ref=$obj->ref; - $reception->ref_supplier=$obj->ref_supplier; + $reception->id = $obj->rowid; + $reception->ref = $obj->ref; + $reception->ref_supplier = $obj->ref_supplier; print '
      '; print $reception->getNomUrl(1); @@ -179,8 +179,8 @@ if ($resql) print ''; if ($obj->commande_fournisseur_id > 0) { - $orderstatic->id=$obj->commande_fournisseur_id; - $orderstatic->ref=$obj->commande_fournisseur_ref; + $orderstatic->id = $obj->commande_fournisseur_id; + $orderstatic->ref = $obj->commande_fournisseur_ref; print $orderstatic->getNomUrl(1); } else print ' '; @@ -200,16 +200,16 @@ else dol_print_error($db); */ $sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut as status, c.billed as billed, s.nom as name, s.rowid as socid"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('supplier_order').")"; -$sql.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")"; -if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.rowid ASC"; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('supplier_order').")"; +$sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")"; +if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY c.rowid ASC"; +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -226,14 +226,14 @@ if ($resql) { $obj = $db->fetch_object($resql); - $orderstatic->id=$obj->rowid; - $orderstatic->ref=$obj->ref; - $orderstatic->ref_supplier=$obj->ref_supplier; - $orderstatic->statut=$obj->status; - $orderstatic->facturee=$obj->billed; + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_supplier = $obj->ref_supplier; + $orderstatic->statut = $obj->status; + $orderstatic->facturee = $obj->billed; - $companystatic->name=$obj->name; - $companystatic->id=$obj->socid; + $companystatic->name = $obj->name; + $companystatic->id = $obj->socid; print '
      '; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 251247a252b..a93003b0ef9 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -29,11 +29,11 @@ require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$userid=GETPOST('userid', 'int'); -$socid=GETPOST('socid', 'int'); +$userid = GETPOST('userid', 'int'); +$socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { @@ -41,11 +41,11 @@ if ($user->socid > 0) $socid = $user->socid; } -$nowyear=strftime("%Y", dol_now()); -$year = GETPOST('year')>0?GETPOST('year'):$nowyear; +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; //$startyear=$year-2; -$startyear=$year-1; -$endyear=$year; +$startyear = $year - 1; +$endyear = $year; $langs->load("reception"); $langs->load("other"); @@ -57,7 +57,7 @@ $langs->load("companies"); * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); @@ -66,7 +66,7 @@ print load_fiche_titre($langs->trans("StatisticsOfReceptions"), $mesg); dol_mkdir($dir); -$stats = new ReceptionStats($db, $socid, '', ($userid>0?$userid:0)); +$stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0)); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); @@ -85,13 +85,13 @@ else $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px1->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px1->SetLegend($legend); @@ -102,7 +102,7 @@ if (! $mesg) $px1->SetYLabel($langs->trans("NbOfReceptions")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfReceptionsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -190,22 +190,22 @@ if (! $mesg) // Show array $data = $stats->getAllByYear(); -$arrayyears=array(); -foreach($data as $val) { - if (! empty($val['year'])) { - $arrayyears[$val['year']]=$val['year']; +$arrayyears = array(); +foreach ($data as $val) { + if (!empty($val['year'])) { + $arrayyears[$val['year']] = $val['year']; } } -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; -$h=0; +$h = 0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php'; +$head[$h][0] = DOL_URL_ROOT.'/commande/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -$type='reception_stats'; +$type = 'reception_stats'; complete_head_from_modules($conf, $langs, null, $head, $h, $type); @@ -233,8 +233,8 @@ print '
      '; print '
      '.$langs->trans("Year").''; - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print '
      '.$langs->trans("NbOfReceptions").''.$langs->trans("AmountAverage").'
      '.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
      '; diff --git a/htdocs/reception/stats/month.php b/htdocs/reception/stats/month.php index 3dd2dd39300..d2cf628e605 100644 --- a/htdocs/reception/stats/month.php +++ b/htdocs/reception/stats/month.php @@ -34,8 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; llxHeader(); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $mesg = ''; @@ -51,7 +51,7 @@ $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=reception $px = new DolGraph(); $mesg = $px->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px->SetData($data); $px->SetMaxValue($px->GetCeilMaxValue()); diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 0de915f8c0a..7d902888cd0 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -41,17 +41,17 @@ $langs->load("receptions"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?>
      trans("Reception"); ?> - global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' getNomUrl(1); ?>
      trans("Total"); ?>
      ' . $langs->trans("ResourceType") . ''.$langs->trans("ResourceType").''; print $object->type_label; print '
      ' . $langs->trans("ResourceType") . ''.$langs->trans("ResourceType").''; print $object->type_label; print '
      ' . $langs->trans("ResourceType") . ''.$langs->trans("ResourceType").''; print $object->type_label; print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); } diff --git a/htdocs/salaries/admin/salaries_extrafields.php b/htdocs/salaries/admin/salaries_extrafields.php index 2ea9ba62919..48f574557ec 100644 --- a/htdocs/salaries/admin/salaries_extrafields.php +++ b/htdocs/salaries/admin/salaries_extrafields.php @@ -28,19 +28,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","salaries")); +$langs->loadLangs(array("admin", "salaries")); $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='payment_salary'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'payment_salary'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -59,11 +59,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject = $langs->transnoentitiesnoconv("Salaries"); -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("SalariesSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SalariesSetup"), $linkback, 'title_setup'); @@ -104,7 +104,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print '

      '; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 39f7fee3397..ac1c08f2948 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -26,20 +26,20 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/salaries.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->projet->enabled)) +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("compta","banks","bills","users","salaries","hrm")); -if (! empty($conf->projet->enabled)) $langs->load("projects"); +$langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm")); +if (!empty($conf->projet->enabled)) $langs->load("projects"); $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); @@ -54,7 +54,7 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); $object = new PaymentSalary($db); @@ -381,52 +381,52 @@ if ($action == 'create') if ($id) { - $head=salaries_prepare_head($object); + $head = salaries_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; + $morehtmlref = '
      '; // Employee - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->fk_user); - $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); + $morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $morehtmlref.='
      '.$langs->trans('Project') . ' '; + $morehtmlref .= '
      '.$langs->trans('Project').' '; if ($user->rights->salaries->write) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
      '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
      '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 5aee0a83a29..44c25b09a13 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -34,17 +34,17 @@ class PaymentSalary extends CommonObject /** * @var string ID to identify managed object */ - public $element='payment_salary'; + public $element = 'payment_salary'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='payment_salary'; + public $table_element = 'payment_salary'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='payment'; + public $picto = 'payment'; public $tms; @@ -112,17 +112,17 @@ class PaymentSalary extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->amount = trim($this->amount); + $this->label = trim($this->label); + $this->note = trim($this->note); // Check parameters if (empty($this->fk_user) || $this->fk_user < 0) { - $this->error='ErrorBadParameter'; + $this->error = 'ErrorBadParameter'; return -1; } @@ -131,38 +131,38 @@ class PaymentSalary extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - $sql.= " tms='".$this->db->idate($this->tms)."',"; - $sql.= " fk_user=".$this->fk_user.","; - $sql.= " datep='".$this->db->idate($this->datep)."',"; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_projet=".((int) $this->fk_project).","; - $sql.= " fk_typepayment=".$this->fk_typepayment."',"; - $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " datesp='".$this->db->idate($this->datesp)."',"; - $sql.= " dateep='".$this->db->idate($this->dateep)."',"; - $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; - $sql.= " fk_user_author=".((int) $this->fk_user_author).","; - $sql.= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); + $sql .= " tms='".$this->db->idate($this->tms)."',"; + $sql .= " fk_user=".$this->fk_user.","; + $sql .= " datep='".$this->db->idate($this->datep)."',"; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " amount=".price2num($this->amount).","; + $sql .= " fk_projet=".((int) $this->fk_project).","; + $sql .= " fk_typepayment=".$this->fk_typepayment."',"; + $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " datesp='".$this->db->idate($this->datesp)."',"; + $sql .= " dateep='".$this->db->idate($this->dateep)."',"; + $sql .= " note='".$this->db->escape($this->note)."',"; + $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; + $sql .= " fk_user_author=".((int) $this->fk_user_author).","; + $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } // Update extrafield - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -170,15 +170,15 @@ class PaymentSalary extends CommonObject } } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_MODIFY', $user); + $result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -202,59 +202,59 @@ class PaymentSalary extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " s.rowid,"; + $sql .= " s.rowid,"; - $sql.= " s.tms,"; - $sql.= " s.fk_user,"; - $sql.= " s.datep,"; - $sql.= " s.datev,"; - $sql.= " s.amount,"; - $sql.= " s.fk_projet as fk_project,"; - $sql.= " s.fk_typepayment,"; - $sql.= " s.num_payment,"; - $sql.= " s.label,"; - $sql.= " s.datesp,"; - $sql.= " s.dateep,"; - $sql.= " s.note,"; - $sql.= " s.fk_bank,"; - $sql.= " s.fk_user_author,"; - $sql.= " s.fk_user_modif,"; - $sql.= " b.fk_account,"; - $sql.= " b.fk_type,"; - $sql.= " b.rappro"; + $sql .= " s.tms,"; + $sql .= " s.fk_user,"; + $sql .= " s.datep,"; + $sql .= " s.datev,"; + $sql .= " s.amount,"; + $sql .= " s.fk_projet as fk_project,"; + $sql .= " s.fk_typepayment,"; + $sql .= " s.num_payment,"; + $sql .= " s.label,"; + $sql .= " s.datesp,"; + $sql .= " s.dateep,"; + $sql .= " s.note,"; + $sql .= " s.fk_bank,"; + $sql .= " s.fk_user_author,"; + $sql .= " s.fk_user_modif,"; + $sql .= " b.fk_account,"; + $sql .= " b.fk_type,"; + $sql .= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql.= " WHERE s.rowid = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql .= " WHERE s.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; + $this->fk_user = $obj->fk_user; $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->fk_project = $obj->fk_project; - $this->type_payement = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; $this->label = $obj->label; $this->datesp = $this->db->jdate($obj->datesp); $this->dateep = $this->db->jdate($obj->dateep); $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; // Retreive all extrafield // fetch optionals attributes and labels @@ -266,7 +266,7 @@ class PaymentSalary extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -282,21 +282,21 @@ class PaymentSalary extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_DELETE', $user); + $result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user); if ($result < 0) return -1; // End call triggers // Delete donation - if (! $error) + if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "payment_salary_extrafields"; - $sql.= " WHERE fk_object=" . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields"; + $sql .= " WHERE fk_object=".$this->id; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; @@ -304,13 +304,13 @@ class PaymentSalary extends CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -327,20 +327,20 @@ class PaymentSalary extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->tms=''; - $this->fk_user=''; - $this->datep=''; - $this->datev=''; - $this->amount=''; - $this->label=''; - $this->datesp=''; - $this->dateep=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_author=''; - $this->fk_user_modif=''; + $this->tms = ''; + $this->fk_user = ''; + $this->datep = ''; + $this->datev = ''; + $this->amount = ''; + $this->label = ''; + $this->datesp = ''; + $this->dateep = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_author = ''; + $this->fk_user_modif = ''; } /** @@ -351,43 +351,43 @@ class PaymentSalary extends CommonObject */ public function create($user) { - global $conf,$langs; + global $conf, $langs; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->amount=price2num(trim($this->amount)); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_modif=trim($this->fk_user_modif); + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); + $this->note = trim($this->note); + $this->fk_bank = trim($this->fk_bank); + $this->fk_user_author = trim($this->fk_user_author); + $this->fk_user_modif = trim($this->fk_user_modif); // Check parameters - if (! $this->label) + if (!$this->label) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } if ($this->fk_user < 0 || $this->fk_user == '') { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); return -4; } if ($this->amount < 0 || $this->amount == '') { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } - if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); return -6; } - if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -7; } @@ -395,40 +395,40 @@ class PaymentSalary extends CommonObject // Insert into llx_payment_salary $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; - $sql.= ", datep"; - $sql.= ", datev"; - $sql.= ", amount"; - $sql.= ", fk_projet"; - $sql.= ", salary"; - $sql.= ", fk_typepayment"; - $sql.= ", num_payment"; - if ($this->note) $sql.= ", note"; - $sql.= ", label"; - $sql.= ", datesp"; - $sql.= ", dateep"; - $sql.= ", fk_user_author"; - $sql.= ", datec"; - $sql.= ", fk_bank"; - $sql.= ", entity"; - $sql.= ") "; - $sql.= " VALUES ("; - $sql.= "'".$this->db->escape($this->fk_user)."'"; - $sql.= ", '".$this->db->idate($this->datep)."'"; - $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", ".$this->amount; - $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); - $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql.= ", ".$this->db->escape($this->type_payment); - $sql.= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->idate($this->datesp)."'"; - $sql.= ", '".$this->db->idate($this->dateep)."'"; - $sql.= ", '".$this->db->escape($user->id)."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", NULL"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + $sql .= ", datep"; + $sql .= ", datev"; + $sql .= ", amount"; + $sql .= ", fk_projet"; + $sql .= ", salary"; + $sql .= ", fk_typepayment"; + $sql .= ", num_payment"; + if ($this->note) $sql .= ", note"; + $sql .= ", label"; + $sql .= ", datesp"; + $sql .= ", dateep"; + $sql .= ", fk_user_author"; + $sql .= ", datec"; + $sql .= ", fk_bank"; + $sql .= ", entity"; + $sql .= ") "; + $sql .= " VALUES ("; + $sql .= "'".$this->db->escape($this->fk_user)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", ".$this->amount; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); + $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); + $sql .= ", ".$this->db->escape($this->type_payment); + $sql .= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->idate($this->datesp)."'"; + $sql .= ", '".$this->db->idate($this->dateep)."'"; + $sql .= ", '".$this->db->escape($user->id)."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", NULL"; + $sql .= ", ".$conf->entity; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -438,20 +438,20 @@ class PaymentSalary extends CommonObject if ($this->id > 0) { - if (! empty($conf->banque->enabled) && ! empty($this->amount)) + if (!empty($conf->banque->enabled) && !empty($this->amount)) { // Insert into llx_bank require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); - $result=$acc->fetch($this->accountid); + $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); // Update extrafield - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -483,28 +483,28 @@ class PaymentSalary extends CommonObject } else { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } - if (! $error) + if (!$error) { // Add link 'payment_salary' in bank_url between payment and bank transaction - $url=DOL_URL_ROOT.'/salaries/card.php?id='; + $url = DOL_URL_ROOT.'/salaries/card.php?id='; - $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); if ($result <= 0) { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } - $fuser=new User($this->db); + $fuser = new User($this->db); $fuser->fetch($this->fk_user); // Add link 'user' in bank_url between operation and bank transaction - $result=$acc->add_url_line( + $result = $acc->add_url_line( $bank_line_id, $this->fk_user, DOL_URL_ROOT.'/user/card.php?id=', @@ -515,19 +515,19 @@ class PaymentSalary extends CommonObject if ($result <= 0) { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_CREATE', $user); + $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); if ($result < 0) $error++; // End call triggers } else $error++; - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -540,7 +540,7 @@ class PaymentSalary extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -557,7 +557,7 @@ class PaymentSalary extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { @@ -587,34 +587,34 @@ class PaymentSalary extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("ShowSalaryPayment") . ''; - $label.= '
      '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("ShowSalaryPayment").''; + $label .= '
      '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('myobjectdao')); @@ -623,22 +623,22 @@ class PaymentSalary extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('salarypayment')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -654,8 +654,8 @@ class PaymentSalary extends CommonObject public function info($id) { $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; - $sql.= ' WHERE ps.rowid = '.$id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; + $sql .= ' WHERE ps.rowid = '.$id; dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); @@ -705,7 +705,7 @@ class PaymentSalary extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage $langs->load('compta'); /*if ($mode == 0) diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index 37e950b1bbe..3601e14bcdc 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -21,8 +21,8 @@ * \ingroup salaries * \brief Fichier de la classe de gestion des stats des salaires */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; /** * Classe permettant la gestion des stats des salaires @@ -57,16 +57,16 @@ class SalariesStats extends Stats $this->socid = $socid; $this->userid = $userid; - $object=new PaymentSalary($this->db); + $object = new PaymentSalary($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; - $this->field='amount'; + $this->field = 'amount'; - $this->where.= " entity = ".$conf->entity; + $this->where .= " entity = ".$conf->entity; if ($this->socid) { - $this->where.=" AND fk_soc = ".$this->socid; + $this->where .= " AND fk_soc = ".$this->socid; } - if (is_array($this->userid) && count($this->userid) > 0) $this->where.=' AND fk_user IN ('.join(',', $this->userid).')'; - elseif ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; + if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')'; + elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; } @@ -78,9 +78,9 @@ class SalariesStats extends Stats public function getNbByYear() { $sql = "SELECT YEAR(datep) as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " GROUP BY dm DESC"; - $sql.= " WHERE ".$this->where; + $sql .= " FROM ".$this->from; + $sql .= " GROUP BY dm DESC"; + $sql .= " WHERE ".$this->where; return $this->_getNbByYear($sql); } @@ -96,13 +96,13 @@ class SalariesStats extends Stats public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(datep) as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE YEAR(datep) = ".$year; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE YEAR(datep) = ".$year; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
      '; return $res; } @@ -118,13 +118,13 @@ class SalariesStats extends Stats public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE date_format(datep,'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
      '; return $res; @@ -139,11 +139,11 @@ class SalariesStats extends Stats public function getAverageByMonth($year) { $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE date_format(datep,'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -156,10 +156,10 @@ class SalariesStats extends Stats public function getAllByYear() { $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index 57cc3c7b8a1..c8de93c0786 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","users","salaries","hrm")); +$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -45,7 +45,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); @@ -57,22 +57,22 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new PaymentSalary($db); $object->fetch($id, $ref); $upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id); -$modulepart='salaries'; +$modulepart = 'salaries'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -87,27 +87,27 @@ if ($object->id) { $object->fetch_thirdparty(); - $head=salaries_prepare_head($object); + $head = salaries_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), -1, 'payment'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; + $morehtmlref = '
      '; - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->fk_user); - $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); - $morehtmlref.='
      '; + $morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1); + $morehtmlref .= '
      '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); @@ -125,8 +125,8 @@ if ($object->id) $modulepart = 'salaries'; $permission = $user->rights->salaries->write; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index a96db0cbd5f..a0572522aeb 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -29,14 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","users","salaries","hrm")); +$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm")); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); @@ -54,15 +54,15 @@ $head = salaries_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'payment'); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
      '; +$morehtmlref = '
      '; -$userstatic=new User($db); +$userstatic = new User($db); $userstatic->fetch($object->fk_user); -$morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); -$morehtmlref.='
      '; +$morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1); +$morehtmlref .= '
      '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index 25c5be2c79d..33082a4ad91 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -27,44 +27,44 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salariesstats.class.php'; // Load translation files required by the page -$langs->loadLangs(array("salaries","companies")); +$langs->loadLangs(array("salaries", "companies")); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$userid=GETPOST('userid', 'int'); if ($userid < 0) $userid=0; -$socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0; +$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0; +$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; $id = GETPOST('id', 'int'); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); -$nowyear=strftime("%Y", dol_now()); -$year = GETPOST('year')>0?GETPOST('year'):$nowyear; +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; //$startyear=$year-2; -$startyear=$year-1; -$endyear=$year; +$startyear = $year - 1; +$endyear = $year; /* * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); -$title=$langs->trans("SalariesStatistics"); -$dir=$conf->salaries->dir_temp; +$title = $langs->trans("SalariesStatistics"); +$dir = $conf->salaries->dir_temp; print load_fiche_titre($title, $mesg); dol_mkdir($dir); -$useridtofilter=$userid; // Filter from parameters +$useridtofilter = $userid; // Filter from parameters $stats = new SalariesStats($db, $socid, $useridtofilter); @@ -80,13 +80,13 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file=sala $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px1->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px1->SetLegend($legend); @@ -96,7 +96,7 @@ if (! $mesg) $px1->SetYLabel($langs->trans("Number")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -112,13 +112,13 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file= $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px2->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px2->SetLegend($legend); @@ -129,7 +129,7 @@ if (! $mesg) $px2->SetYLabel($langs->trans("Amount")); $px2->SetShading(3); $px2->SetHorizTickIncrement(1); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountTotal")); $px2->draw($filenameamount, $fileurlamount); @@ -143,13 +143,13 @@ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file=salari $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px3->SetData($data); - $i = $startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px3->SetLegend($legend); @@ -160,7 +160,7 @@ if (! $mesg) $px3->SetHeight($HEIGHT); $px3->SetShading(3); $px3->SetHorizTickIncrement(1); - $px3->mode='depth'; + $px3->mode = 'depth'; $px3->SetTitle($langs->trans("AmountAverage")); $px3->draw($filename_avg, $fileurl_avg); @@ -169,16 +169,16 @@ if (! $mesg) // Show array $data = $stats->getAllByYear(); -$arrayyears=array(); -foreach($data as $val) { - $arrayyears[$val['year']]=$val['year']; +$arrayyears = array(); +foreach ($data as $val) { + $arrayyears[$val['year']] = $val['year']; } -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; -$h=0; +$h = 0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/salaries/stats/index.php'; +$head[$h][0] = DOL_URL_ROOT.'/salaries/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; @@ -203,7 +203,7 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0 print '
      '.$langs->trans("Year").''; -if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; +if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print '
      '.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
      '.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).'
      '; diff --git a/htdocs/societe/admin/contact_extrafields.php b/htdocs/societe/admin/contact_extrafields.php index 86f40ee7a6c..2e657805b96 100644 --- a/htdocs/societe/admin/contact_extrafields.php +++ b/htdocs/societe/admin/contact_extrafields.php @@ -34,13 +34,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='socpeople'; //Must be the $element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'socpeople'; //Must be the $element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -57,13 +57,13 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("ContactsAddresses"); +$textobject = $langs->transnoentitiesnoconv("ContactsAddresses"); -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; llxHeader('', $langs->trans("CompanySetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); @@ -104,7 +104,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
      "; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php index 11a56314b02..f0812485211 100644 --- a/htdocs/societe/admin/societe_extrafields.php +++ b/htdocs/societe/admin/societe_extrafields.php @@ -34,13 +34,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='societe'; //Must be the $element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'societe'; //Must be the $element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -57,13 +57,13 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("ThirdParty"); +$textobject = $langs->transnoentitiesnoconv("ThirdParty"); -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; llxHeader('', $langs->trans("CompanySetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); @@ -104,7 +104,7 @@ if ($action == 'create') /* Edition d'un champ optionnel */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print '
      '; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 1ba29e5e190..dba483c52eb 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -36,21 +36,21 @@ $langs->loadLangs(array("companies", "bills", "propal", "orders")); if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); +$search_agenda_label = GETPOST('search_agenda_label'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -106,18 +106,18 @@ if ($socid > 0) $object = new Societe($db); $result = $object->fetch($socid); - $title=$langs->trans("Agenda"); - if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $title = $langs->trans("Agenda"); + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; llxHeader('', $title); - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
      '; @@ -154,29 +154,29 @@ if ($socid > 0) //print '
      '; - $newcardbutton=''; - if (! empty($conf->agenda->enabled)) + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) { - if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { - $newcardbutton.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } } - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
      '; - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param = '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, ''); //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); // List of all actions - $filters=array(); - $filters['search_agenda_label']=$search_agenda_label; + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 44e05813314..4fe737ca31c 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -22,21 +22,21 @@ * \brief File to return Ajax response on thirdparty list request */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); require '../../main.inc.php'; -$htmlname=GETPOST('htmlname', 'alpha'); -$filter=GETPOST('filter', 'alpha'); -$outjson=(GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); -$action=GETPOST('action', 'alpha'); -$id=GETPOST('id', 'int'); -$showtype=GETPOST('showtype', 'int'); +$htmlname = GETPOST('htmlname', 'alpha'); +$filter = GETPOST('filter', 'alpha'); +$outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); +$action = GETPOST('action', 'alpha'); +$id = GETPOST('id', 'int'); +$showtype = GETPOST('showtype', 'int'); /* @@ -48,14 +48,14 @@ $showtype=GETPOST('showtype', 'int'); dol_syslog(join(',', $_GET)); //print_r($_GET); -if (! empty($action) && $action == 'fetch' && ! empty($id)) +if (!empty($action) && $action == 'fetch' && !empty($id)) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $outjson=array(); + $outjson = array(); $object = new Societe($db); - $ret=$object->fetch($id); + $ret = $object->fetch($id); if ($ret > 0) { $outref = $object->ref; @@ -80,15 +80,15 @@ else $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $id = (! empty($match[0]) ? $match[0] : ''); + $id = (!empty($match[0]) ? $match[0] : ''); // When used from jQuery, the search term is added as GET param "term". - $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):'')); + $searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); - if (! $searchkey) return; + if (!$searchkey) return; - if (! is_object($form)) $form = new Form($db); - $arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); + if (!is_object($form)) $form = new Form($db); + $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); $db->close(); diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index f7bc9d4e40c..dcf0b1a4483 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -23,12 +23,12 @@ * \brief File to return Ajax response on third parties request */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); require '../main.inc.php'; @@ -55,43 +55,43 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) $return_arr = array(); // Define filter on text typed - $socid = $_GET['newcompany']?$_GET['newcompany']:''; - if (! $socid) $socid = $_GET['socid']?$_GET['socid']:''; - if (! $socid) $socid = $_GET['id_fourn']?$_GET['id_fourn']:''; + $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; + if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; $sql = "SELECT rowid, nom"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if ($socid) { - $sql.=" AND ("; + $sql .= " AND ("; // Add criteria on name/code - if (! empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index + if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index { - $sql.="nom LIKE '" . $db->escape($socid) . "%'"; - $sql.=" OR code_client LIKE '" . $db->escape($socid) . "%'"; - $sql.=" OR code_fournisseur LIKE '" . $db->escape($socid) . "%'"; + $sql .= "nom LIKE '".$db->escape($socid)."%'"; + $sql .= " OR code_client LIKE '".$db->escape($socid)."%'"; + $sql .= " OR code_fournisseur LIKE '".$db->escape($socid)."%'"; } else { - $sql.="nom LIKE '%" . $db->escape($socid) . "%'"; - $sql.=" OR code_client LIKE '%" . $db->escape($socid) . "%'"; - $sql.=" OR code_fournisseur LIKE '%" . $db->escape($socid) . "%'"; + $sql .= "nom LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR code_client LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'"; } - if (! empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql.=" OR rowid = '" . $db->escape($socid) . "'"; - $sql.=")"; + if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR rowid = '".$db->escape($socid)."'"; + $sql .= ")"; } //if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters - $sql.= " ORDER BY nom ASC"; + $sql .= " ORDER BY nom ASC"; //dol_syslog("ajaxcompanies", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { while ($row = $db->fetch_array($resql)) { - $label=$row['nom']; - if ($socid) $label=preg_replace('/('.preg_quote($socid, '/').')/i', '$1', $label, 1); + $label = $row['nom']; + if ($socid) $label = preg_replace('/('.preg_quote($socid, '/').')/i', '$1', $label, 1); $row_array['label'] = $label; $row_array['value'] = $row['nom']; $row_array['key'] = $row['rowid']; @@ -103,10 +103,10 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) } else { - echo json_encode(array('nom'=>'Error','label'=>'Error','key'=>'Error','value'=>'Error')); + echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); } } else { - echo json_encode(array('nom'=>'ErrorBadParameter','label'=>'ErrorBadParameter','key'=>'ErrorBadParameter','value'=>'ErrorBadParameter')); + echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); } diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php index 21ee895629f..dfc4ffd9015 100644 --- a/htdocs/societe/ajaxcountries.php +++ b/htdocs/societe/ajaxcountries.php @@ -22,16 +22,16 @@ * \brief File to return Ajax response on country request */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); require '../main.inc.php'; -$country=GETPOST('country', 'alpha'); +$country = GETPOST('country', 'alpha'); /* @@ -50,25 +50,25 @@ print ' diff --git a/htdocs/societe/canvas/individual/actions_card_individual.class.php b/htdocs/societe/canvas/individual/actions_card_individual.class.php index ebd90fe7c46..9f236c8015e 100644 --- a/htdocs/societe/canvas/individual/actions_card_individual.class.php +++ b/htdocs/societe/canvas/individual/actions_card_individual.class.php @@ -41,11 +41,11 @@ class ActionsCardIndividual extends ActionsCardCommon */ public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } @@ -59,11 +59,11 @@ class ActionsCardIndividual extends ActionsCardCommon { global $langs; - $out=''; + $out = ''; - if ($action == 'view') $out.= $langs->trans("Individual"); - if ($action == 'edit') $out.= $langs->trans("EditCompany"); - if ($action == 'create') $out.= $langs->trans("NewCompany"); + if ($action == 'view') $out .= $langs->trans("Individual"); + if ($action == 'edit') $out .= $langs->trans("EditCompany"); + if ($action == 'create') $out .= $langs->trans("NewCompany"); return $out; } diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index f77233816e0..649d1bf8aca 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -17,7 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -58,7 +58,7 @@ if (empty($conf) || ! is_object($conf)) trans('LastName'); ?> - global->SOCIETE_USEPREFIX)) { ?> + global->SOCIETE_USEPREFIX)) { ?> trans('Prefix'); ?> @@ -114,7 +114,7 @@ if (empty($conf) || ! is_object($conf)) barcode->enabled)) { ?> +if (!empty($conf->barcode->enabled)) { ?> trans('Gencod'); ?> @@ -151,13 +151,13 @@ if (! empty($conf->barcode->enabled)) { ?> - trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY?'*':''); ?> + trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY ? '*' : ''); ?> trans('Web'); ?> -global->MAIN_MULTILANGS)) { ?> +global->MAIN_MULTILANGS)) { ?> trans("DefaultLang"); ?> control->tpl['select_lang']; ?> @@ -169,7 +169,7 @@ if (! empty($conf->barcode->enabled)) { ?> control->tpl['yn_assujtva']; ?> -control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> +control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> rights->societe->client->voir) { ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php index 60a6e18c07b..1571709868e 100644 --- a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php @@ -17,7 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -50,7 +50,7 @@ if (empty($conf) || ! is_object($conf)) -global->SOCIETE_USEPREFIX)) { ?> +global->SOCIETE_USEPREFIX)) { ?> trans("Prefix"); ?> @@ -118,7 +118,7 @@ if ($this->control->tpl['fournisseur']) { } ?> -barcode->enabled)) { ?> +barcode->enabled)) { ?> trans('Gencod'); ?> @@ -155,13 +155,13 @@ if ($this->control->tpl['fournisseur']) { - trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY?'*':''); ?> + trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY ? '*' : ''); ?> trans('Web'); ?> -global->MAIN_MULTILANGS)) { ?> +global->MAIN_MULTILANGS)) { ?> trans("DefaultLang"); ?> control->tpl['select_lang']; ?> @@ -173,7 +173,7 @@ if ($this->control->tpl['fournisseur']) { control->tpl['yn_assujtva']; ?> -control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> +control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
      diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index b1e5d052adc..14c8822dc9e 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -16,7 +16,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -42,7 +42,7 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet control->tpl['showrefnav']; ?> -global->SOCIETE_USEPREFIX)) { ?> +global->SOCIETE_USEPREFIX)) { ?> trans('Prefix'); ?> control->tpl['prefix_comm']; ?> @@ -71,7 +71,7 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet -barcode->enabled)) { ?> +barcode->enabled)) { ?> trans('Gencod'); ?> control->tpl['barcode']; ?> @@ -119,14 +119,14 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet control->tpl['tva_assuj']; ?> -control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> +control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> trans("Type"); ?> control->tpl['typent']; ?> -global->MAIN_MULTILANGS)) { ?> +global->MAIN_MULTILANGS)) { ?> trans("DefaultLang"); ?> control->tpl['default_lang']; ?> @@ -166,10 +166,10 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet - control->tpl['sales_representatives']; ?> + control->tpl['sales_representatives']; ?> -adherent->enabled)) { ?> +adherent->enabled)) { ?> trans("LinkedToDolibarrMember"); ?> control->tpl['linked_member']; ?> @@ -188,7 +188,7 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet rights->societe->supprimer) { ?> use_javascript_ajax) { ?> trans('Delete'); ?> - + ">trans('Delete'); ?> @@ -202,10 +202,10 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet /* * Documents generes */ -$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; -$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; -$genallowed=$user->rights->societe->lire; -$delallowed=$user->rights->societe->creer; +$filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; +$urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; +$genallowed = $user->rights->societe->lire; +$delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); ?> @@ -219,12 +219,12 @@ print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallo \n"; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 54068f26265..20ada9bfbaf 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -931,7 +931,7 @@ else * Creation */ $private = GETPOST("private", "int"); - if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! GETPOSTISSET('private')) $private = 1; + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !GETPOSTISSET('private')) $private = 1; if (empty($private)) $private = 0; // Load object modCodeTiers diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 1d5fa1a1f2a..8d004fa4c79 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -28,15 +28,15 @@ require_once NUSOAP_PATH.'/nusoap.php'; $langs->load("companies"); //http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl -$WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService'; +$WS_DOL_URL = 'http://ec.europa.eu/taxation_customs/vies/services/checkVatService'; //$WS_DOL_URL_WSDL=$WS_DOL_URL.'?wsdl'; -$WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'; -$WS_METHOD ='checkVat'; +$WS_DOL_URL_WSDL = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'; +$WS_METHOD = 'checkVat'; -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; llxHeader('', $langs->trans("VATIntraCheckableOnEUSite")); @@ -46,7 +46,7 @@ print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_se $vatNumber = GETPOST("vatNumber", 'alpha'); -if (! $vatNumber) +if (!$vatNumber) { print '
      '; print ''.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'
      '; @@ -55,8 +55,8 @@ else { $vatNumber = preg_replace('/\^\w/', '', $vatNumber); $vatNumber = str_replace(array(' ', '.'), '', $vatNumber); - $countryCode=substr($vatNumber, 0, 2); - $vatNumber=substr($vatNumber, 2); + $countryCode = substr($vatNumber, 0, 2); + $vatNumber = substr($vatNumber, 2); print ''.$langs->trans("Country").': '.$countryCode.'
      '; print ''.$langs->trans("VATIntraShort").': '.$vatNumber.'
      '; @@ -69,7 +69,7 @@ else // Set the WebService URL dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL); require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $params=getSoapParams(); + $params = getSoapParams(); //ini_set('default_socket_timeout', $params['response_timeout']); //$soapclient = new SoapClient($WS_DOL_URL_WSDL,$params); $soapclient = new nusoap_client($WS_DOL_URL_WSDL, true, $params['proxy_host'], $params['proxy_port'], $params['proxy_login'], $params['proxy_password'], $params['connection_timeout'], $params['response_timeout']); @@ -95,33 +95,33 @@ else //print $soapclient->request.'
      '; //print $soapclient->response.'
      '; - $messagetoshow=''; + $messagetoshow = ''; print ''.$langs->trans("Response").':
      '; // Service indisponible - if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring'])) + if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring'])) { print ''.$langs->trans("ErrorServiceUnavailableTryLater").'
      '; - $messagetoshow=$soapclient->response; + $messagetoshow = $soapclient->response; } elseif (preg_match('/TIMEOUT/i', $result['faultstring'])) { print ''.$langs->trans("ErrorServiceUnavailableTryLater").'
      '; - $messagetoshow=$soapclient->response; + $messagetoshow = $soapclient->response; } elseif (preg_match('/SERVER_BUSY/i', $result['faultstring'])) { print ''.$langs->trans("ErrorServiceUnavailableTryLater").'
      '; - $messagetoshow=$soapclient->response; + $messagetoshow = $soapclient->response; } elseif ($result['faultstring']) { print ''.$langs->trans("Error").'
      '; - $messagetoshow=$result['faultstring']; + $messagetoshow = $result['faultstring']; } // Syntaxe ko elseif (preg_match('/INVALID_INPUT/i', $result['faultstring']) - || ($result['requestDate'] && ! $result['valid'])) + || ($result['requestDate'] && !$result['valid'])) { if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'
      '; print $langs->trans("VATIntraSyntaxIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
      '; @@ -140,7 +140,7 @@ else } else { - if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true')) + if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true')) { print ''.$langs->trans("Yes").''; print '
      '; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 5f031137c1f..d9214a538a2 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1687,7 +1687,7 @@ class Thirdparties extends DolibarrApi unset($object->particulier); unset($object->prefix_comm); - unset($object->commercial_id); // This property is used in create/update only. It does not exists in read mode because there is several sales representatives. + unset($object->commercial_id); // This property is used in create/update only. It does not exists in read mode because there is several sales representatives. unset($object->total_ht); unset($object->total_tva); diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index c345d195935..06c56b027cd 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -29,9 +29,9 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; */ class Client extends Societe { - public $next_prev_filter="te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method + public $next_prev_filter = "te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method - public $cacheprospectstatus=array(); + public $cacheprospectstatus = array(); /** @@ -58,28 +58,28 @@ class Client extends Societe // phpcs:enable global $user; - $this->nb=array("customers" => 0,"prospects" => 0); + $this->nb = array("customers" => 0, "prospects" => 0); $clause = "WHERE"; $sql = "SELECT count(s.rowid) as nb, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." s.client IN (1,2,3)"; - $sql.= ' AND s.entity IN ('.getEntity($this->element).')'; - $sql.= " GROUP BY s.client"; + $sql .= " ".$clause." s.client IN (1,2,3)"; + $sql .= ' AND s.entity IN ('.getEntity($this->element).')'; + $sql .= " GROUP BY s.client"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"]+=$obj->nb; - if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"]+=$obj->nb; + if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb; + if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb; } $this->db->free($resql); return 1; @@ -87,7 +87,7 @@ class Client extends Societe else { dol_print_error($this->db); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -102,14 +102,14 @@ class Client extends Societe { global $langs; - $sql="SELECT id, code, libelle as label FROM ".MAIN_DB_PREFIX."c_stcomm"; - if ($active >= 0) $sql.=" WHERE active = ".$active; - $resql=$this->db->query($sql); - $num=$this->db->num_rows($resql); - $i=0; + $sql = "SELECT id, code, libelle as label FROM ".MAIN_DB_PREFIX."c_stcomm"; + if ($active >= 0) $sql .= " WHERE active = ".$active; + $resql = $this->db->query($sql); + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - $this->cacheprospectstatus[$obj->id]=array('id'=>$obj->id, 'code'=>$obj->code, 'label'=> ($langs->trans("ST_".strtoupper($obj->code))=="ST_".strtoupper($obj->code))?$obj->label:$langs->trans("ST_".strtoupper($obj->code))); + $obj = $this->db->fetch_object($resql); + $this->cacheprospectstatus[$obj->id] = array('id'=>$obj->id, 'code'=>$obj->code, 'label'=> ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code))); $i++; } return 1; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 5cfe6fa3709..7211802721e 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -142,45 +142,45 @@ class CompanyBankAccount extends Account global $conf; $error = 0; - if (! $this->id) return -1; + if (!$this->id) return -1; if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; - $sql.= " bank = '" .$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",default_rib = ".$this->default_rib; + $sql .= " bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",default_rib = ".$this->default_rib; if ($conf->prelevement->enabled) { - $sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; - $sql.= ",rum = '".$this->db->escape($this->rum)."'"; - $sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); + $sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; + $sql .= ",rum = '".$this->db->escape($this->rum)."'"; + $sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); } if (trim($this->label) != '') - $sql.= ",label = '".$this->db->escape($this->label)."'"; + $sql .= ",label = '".$this->db->escape($this->label)."'"; else - $sql.= ",label = NULL"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= ",label = NULL"; + $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); if ($result) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_MODIFY', $user); + $result = $this->call_trigger('COMPANY_RIB_MODIFY', $user); if ($result < 0) $error++; // End call triggers - if(! $error ) + if (!$error) { return 1; } diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 6cd09ce49c4..5ba268f6687 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -84,7 +84,7 @@ class CompanyPaymentMode extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'Rowid', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10), 'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15), 'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-2, 'position'=>30), @@ -232,8 +232,8 @@ class CompanyPaymentMode extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; } /** @@ -245,7 +245,7 @@ class CompanyPaymentMode extends CommonObject */ public function create(User $user, $notrigger = false) { - $idpayment = $this->createCommon($user, $notrigger); + $idpayment = $this->createCommon($user, $notrigger); return $idpayment; } @@ -313,8 +313,8 @@ class CompanyPaymentMode extends CommonObject */ public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '') { - if ($socid) $morewhere.= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1"; - if ($type) $morewhere.= " AND type = '".$this->db->escape($type)."'"; + if ($socid) $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1"; + if ($type) $morewhere .= " AND type = '".$this->db->escape($type)."'"; $result = $this->fetchCommon($id, $ref, $morewhere); //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); @@ -375,45 +375,45 @@ class CompanyPaymentMode extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("CompanyPaymentMode") . ''; - $label.= '
      '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("CompanyPaymentMode").''; + $label .= '
      '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowCompanyPaymentMode"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowCompanyPaymentMode"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -430,7 +430,7 @@ class CompanyPaymentMode extends CommonObject public function setAsDefault($id = 0, $alltypes = 0) { $sql1 = "SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql1.= " WHERE rowid = ".($id?$id:$this->id); + $sql1 .= " WHERE rowid = ".($id ? $id : $this->id); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result1 = $this->db->query($sql1); @@ -450,14 +450,14 @@ class CompanyPaymentMode extends CommonObject $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms"; - $sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc; - if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'"; + $sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc; + if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'"; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3.= " WHERE rowid = ".$obj->id; - if ($type) $sql3.= " AND type = '".$this->db->escape($type)."'"; + $sql3 .= " WHERE rowid = ".$obj->id; + if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'"; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result3 = $this->db->query($sql3); @@ -528,10 +528,10 @@ class CompanyPaymentMode extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -542,7 +542,7 @@ class CompanyPaymentMode extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -556,7 +556,7 @@ class CompanyPaymentMode extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 3664d8fd848..ad7383d81af 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -33,13 +33,13 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Societe($db); if ($socid > 0) $object->fetch($socid); // Sort & Order fields -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -47,26 +47,26 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='dateprint'; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'dateprint'; // Search fields -$sref=GETPOST("sref"); -$sprod_fulldescr=GETPOST("sprod_fulldescr"); -$month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); +$sref = GETPOST("sref"); +$sprod_fulldescr = GETPOST("sprod_fulldescr"); +$month = GETPOST('month', 'int'); +$year = GETPOST('year', 'int'); // Clean up on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $sref=''; - $sprod_fulldescr=''; - $year=''; - $month=''; + $sref = ''; + $sprod_fulldescr = ''; + $year = ''; + $month = ''; } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); -$type_element = GETPOST('type_element')?GETPOST('type_element'):''; +$type_element = GETPOST('type_element') ?GETPOST('type_element') : ''; // Load translation files required by the page $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); @@ -79,8 +79,8 @@ $hookmanager->initHooks(array('consumptionthirdparty')); * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -91,11 +91,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e $form = new Form($db); $formother = new FormOther($db); -$productstatic=new Product($db); +$productstatic = new Product($db); $title = $langs->trans("Referers", $object->name); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); if (empty($socid)) @@ -109,14 +109,14 @@ dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"), -1, 'company') $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
      '; print '
      '; print ''; -if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } @@ -131,19 +131,19 @@ if ($object->client) if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; - $thirdTypeArray['customer']=$langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); + $thirdTypeArray['customer'] = $langs->trans("customer"); + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } -if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter']=$langs->transnoentitiesnoconv('Interventions'); +if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); if ($object->fournisseur) { @@ -153,15 +153,15 @@ if ($object->fournisseur) if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $obj = $db->fetch_object($resql); $nbCmdsFourn = $obj->nb; - $thirdTypeArray['supplier']=$langs->trans("supplier"); - if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice']=$langs->transnoentitiesnoconv('SuppliersInvoices'); - if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']=$langs->transnoentitiesnoconv('SuppliersOrders'); - if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); + $thirdTypeArray['supplier'] = $langs->trans("supplier"); + if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); + if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); + if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals'); } print '
      '.$langs->trans('Prefix').''.$object->prefix_comm.'
      '; @@ -174,7 +174,7 @@ print '
      '; print '
      '; print ''; -$sql_select=''; +$sql_select = ''; /*if ($type_element == 'action') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -188,178 +188,178 @@ $sql_select=''; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $documentstatic=new Fichinter($db); + $documentstatic = new Fichinter($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, '; - $tables_from = MAIN_DB_PREFIX."fichinter as f LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as d ON d.fk_fichinter = f.rowid"; // Must use left join to work also with option that disable usage of lines. + $tables_from = MAIN_DB_PREFIX."fichinter as f LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as d ON d.fk_fichinter = f.rowid"; // Must use left join to work also with option that disable usage of lines. $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND f.entity = ".$conf->entity; + $where .= " AND f.entity = ".$conf->entity; $dateprint = 'f.datec'; - $doc_number='f.ref'; + $doc_number = 'f.ref'; } if ($type_element == 'invoice') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $documentstatic=new Facture($db); + $documentstatic = new Facture($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_facture = f.rowid"; - $where.= " AND f.entity IN (".getEntity('invoice').")"; + $where .= " AND d.fk_facture = f.rowid"; + $where .= " AND f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; - $doc_number='f.ref'; - $thirdTypeSelect='customer'; + $doc_number = 'f.ref'; + $thirdTypeSelect = 'customer'; } if ($type_element == 'propal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $documentstatic=new Propal($db); + $documentstatic = new Propal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."propal as c,".MAIN_DB_PREFIX."propaldet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_propal = c.rowid"; - $where.= " AND c.entity = ".$conf->entity; + $where .= " AND d.fk_propal = c.rowid"; + $where .= " AND c.entity = ".$conf->entity; $datePrint = 'c.datep'; - $doc_number='c.ref'; - $thirdTypeSelect='customer'; + $doc_number = 'c.ref'; + $thirdTypeSelect = 'customer'; } if ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $documentstatic=new Commande($db); + $documentstatic = new Commande($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_commande = c.rowid"; - $where.= " AND c.entity = ".$conf->entity; + $where .= " AND d.fk_commande = c.rowid"; + $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_commande'; - $doc_number='c.ref'; - $thirdTypeSelect='customer'; + $doc_number = 'c.ref'; + $thirdTypeSelect = 'customer'; } if ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $documentstatic=new FactureFournisseur($db); + $documentstatic = new FactureFournisseur($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d"; $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_facture_fourn = f.rowid"; - $where.= " AND f.entity = ".$conf->entity; + $where .= " AND d.fk_facture_fourn = f.rowid"; + $where .= " AND f.entity = ".$conf->entity; $dateprint = 'f.datef'; - $doc_number='f.ref'; - $thirdTypeSelect='supplier'; + $doc_number = 'f.ref'; + $thirdTypeSelect = 'supplier'; } if ($type_element == 'supplier_proposal') { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - $documentstatic=new SupplierProposal($db); + $documentstatic = new SupplierProposal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_supplier_proposal = c.rowid"; - $where.= " AND c.entity = ".$conf->entity; + $where .= " AND d.fk_supplier_proposal = c.rowid"; + $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; - $doc_number='c.ref'; - $thirdTypeSelect='supplier'; + $doc_number = 'c.ref'; + $thirdTypeSelect = 'supplier'; } if ($type_element == 'supplier_order') { // Supplier : Show products from orders. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $documentstatic=new CommandeFournisseur($db); + $documentstatic = new CommandeFournisseur($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_commande = c.rowid"; - $where.= " AND c.entity = ".$conf->entity; + $where .= " AND d.fk_commande = c.rowid"; + $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; - $doc_number='c.ref'; - $thirdTypeSelect='supplier'; + $doc_number = 'c.ref'; + $thirdTypeSelect = 'supplier'; } if ($type_element == 'contract') { // Order require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $documentstatic=new Contrat($db); - $documentstaticline=new ContratLigne($db); + $documentstatic = new Contrat($db); + $documentstaticline = new ContratLigne($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, '; $tables_from = MAIN_DB_PREFIX."contrat as c,".MAIN_DB_PREFIX."contratdet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_contrat = c.rowid"; - $where.= " AND c.entity = ".$conf->entity; + $where .= " AND d.fk_contrat = c.rowid"; + $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; - $doc_number='c.ref'; - $thirdTypeSelect='customer'; + $doc_number = 'c.ref'; + $thirdTypeSelect = 'customer'; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook if (!empty($sql_select)) { $sql = $sql_select; - $sql.= ' d.description as description,'; - if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; - if ($type_element == 'supplier_proposal') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; - if ($type_element == 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; - if ($type_element != 'fichinter') $sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,'; - $sql.= " s.rowid as socid "; - if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from; - if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; - $sql.= $where; - $sql.= dolSqlDateFilter($dateprint, 0, $month, $year); - if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; + $sql .= ' d.description as description,'; + if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; + if ($type_element == 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; + if ($type_element == 'contract') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; + if ($type_element != 'fichinter') $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,'; + $sql .= " s.rowid as socid "; + if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from; + if ($type_element != 'fichinter') $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; + $sql .= $where; + $sql .= dolSqlDateFilter($dateprint, 0, $month, $year); + if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; if ($sprod_fulldescr) { - $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; - $sql.=")"; + $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql .= ")"; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); - $resql=$db->query($sql); + $resql = $db->query($sql); $totalnboflines = $db->num_rows($resql); - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); //print $sql; } -$disabled=0; -$showempty=2; -if (empty($elementTypeArray) && ! $object->client && ! $object->fournisseur) +$disabled = 0; +$showempty = 2; +if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) { - $showempty=$langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); - $disabled=1; + $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); + $disabled = 1; } // Define type of elements $typeElementString = $form->selectarray("type_element", $elementTypeArray, GETPOST('type_element'), $showempty, 0, 0, '', 0, 0, $disabled, '', 'maxwidth150onsmartphone'); $button = ''; -$param=''; -$param.="&sref=".urlencode($sref); -$param.="&month=".urlencode($month); -$param.="&year=".urlencode($year); -$param.="&sprod_fulldescr=".urlencode($sprod_fulldescr); -$param.="&socid=".urlencode($socid); -$param.="&type_element=".urlencode($type_element); +$param = ''; +$param .= "&sref=".urlencode($sref); +$param .= "&month=".urlencode($month); +$param .= "&year=".urlencode($year); +$param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); +$param .= "&socid=".urlencode($socid); +$param .= "&type_element=".urlencode($type_element); -$total_qty=0; +$total_qty = 0; if ($sql_select) { - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $num = $db->num_rows($resql); - $param="&socid=".$socid."&type_element=".$type_element; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sprod_fulldescr) $param.= "&sprod_fulldescr=".urlencode($sprod_fulldescr); - if ($sref) $param.= "&sref=".urlencode($sref); - if ($month) $param.= "&month=".$month; - if ($year) $param.= "&year=".$year; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = "&socid=".$socid."&type_element=".$type_element; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); + if ($sref) $param .= "&sref=".urlencode($sref); + if ($month) $param .= "&month=".$month; + if ($year) $param .= "&year=".$year; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); @@ -372,8 +372,8 @@ if ($sql_select) print ''; print ''; print ''; // date - print $formother->select_month($month?$month:-1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year?$year:-1, 'year', 1, 20, 1); + print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); print ''; print ''; print ''; @@ -385,7 +385,7 @@ if ($sql_select) print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; print ''; @@ -405,16 +405,16 @@ if ($sql_select) $i = 0; while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) { - $documentstatic->id=$objp->doc_id; - $documentstatic->ref=$objp->doc_number; - $documentstatic->type=$objp->doc_type; - $documentstatic->fk_statut=$objp->status; - $documentstatic->fk_status=$objp->status; - $documentstatic->statut=$objp->status; - $documentstatic->status=$objp->status; - $documentstatic->paye=$objp->paid; + $documentstatic->id = $objp->doc_id; + $documentstatic->ref = $objp->doc_number; + $documentstatic->type = $objp->doc_type; + $documentstatic->fk_statut = $objp->status; + $documentstatic->fk_status = $objp->status; + $documentstatic->statut = $objp->status; + $documentstatic->status = $objp->status; + $documentstatic->paye = $objp->paid; - if (is_object($documentstaticline)) $documentstaticline->statut=$objp->status; + if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status; print ''; print ''; @@ -437,58 +437,58 @@ if ($sql_select) print ''; // Define text, description and type - $text=''; $description=''; $type=0; + $text = ''; $description = ''; $type = 0; // Code to show product duplicated from commonobject->printObjectLine if ($objp->fk_product > 0) { $product_static = new Product($db); - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->fk_product; - $product_static->ref=$objp->ref; - $product_static->entity=$objp->pentity; - $text=$product_static->getNomUrl(1); + $product_static->type = $objp->fk_product_type; + $product_static->id = $objp->fk_product; + $product_static->ref = $objp->ref; + $product_static->entity = $objp->pentity; + $text = $product_static->getNomUrl(1); } // Product if ($objp->fk_product > 0) { // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); $prod->fetch($objp->fk_product); $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) $newlang=$object->default_lang; - if (! empty($newlang)) + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (empty($newlang)) $newlang = $object->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; } else { $label = $objp->product_label; } - $text.= ' - '.(! empty($objp->label)?$objp->label:$label); - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); + $text .= ' - '.(!empty($objp->label) ? $objp->label : $label); + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); } if (($objp->info_bits & 2) == 2) { ?> trans("ShowReduc"), 'reduc').' '; - if ($objp->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); - elseif ($objp->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); - elseif ($objp->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid"); + if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit"); + elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived"); + elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; ?> @@ -498,33 +498,33 @@ if ($sql_select) { if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); } if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; } else { - echo ($txt?' - ':'').dol_htmlentitiesbr($objp->description); + echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); } } } @@ -537,18 +537,18 @@ if ($sql_select) echo get_date_range($objp->date_start, $objp->date_end); // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (! empty($objp->description) && $objp->description!=$objp->product_label)?'
      '.dol_htmlentitiesbr($objp->description):''; + print (!empty($objp->description) && $objp->description != $objp->product_label) ? '
      '.dol_htmlentitiesbr($objp->description) : ''; } } else { - if (! empty($objp->label) || ! empty($objp->description)) + if (!empty($objp->label) || !empty($objp->description)) { - if ($type==1) $text = img_object($langs->trans('Service'), 'service'); + if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($objp->label)) { - $text.= ' '.$objp->label.''; + if (!empty($objp->label)) { + $text .= ' '.$objp->label.''; echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, '', '', $i, 0, ''); } else { echo $text.' '.dol_htmlentitiesbr($objp->description); @@ -581,25 +581,25 @@ if ($sql_select) print ''; //print ''.$prodreftxt.''; - if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) $objp->prod_qty=-($objp->prod_qty); + if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) $objp->prod_qty = -($objp->prod_qty); print ''.$objp->prod_qty.''; - $total_qty+=$objp->prod_qty; + $total_qty += $objp->prod_qty; print ''.price($objp->total_ht).''; - $total_ht+=$objp->total_ht; + $total_ht += $objp->total_ht; - print ''.price($objp->total_ht/(empty($objp->prod_qty)?1:$objp->prod_qty)).''; + print ''.price($objp->total_ht / (empty($objp->prod_qty) ? 1 : $objp->prod_qty)).''; print "\n"; $i++; } print ''; - print '' . $langs->trans('Total') . ''; + print ''.$langs->trans('Total').''; print ''; - print '' . $total_qty . ''; - print '' . price($total_ht) . ''; - print '' . price($total_ht/(empty($total_qty)?1:$total_qty)) . ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; + print ''.price($total_ht / (empty($total_qty) ? 1 : $total_qty)).''; print ""; print '
      '; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 992892e96db..f22fb1ec5b6 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -56,23 +56,23 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield=$conf->global->MAIN_DOC_SORT_FIELD; } -if (! empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder=$conf->global->MAIN_DOC_SORT_ORDER; } +if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; } +if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; } -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="position_name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; $object = new Societe($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; - $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id, 0, 0, 0, $object, 'thirdparty'); + $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; + $courrier_dir = $conf->societe->multidir_output[$object->entity]."/courrier/".get_exdir($object->id, 0, 0, 0, $object, 'thirdparty'); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartydocument','globalcard')); +$hookmanager->initHooks(array('thirdpartydocument', 'globalcard')); @@ -99,25 +99,25 @@ if ($object->id) /* * Show tabs */ - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); - $form=new Form($db); + $form = new Form($db); dol_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
      '; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 5b89c086c1f..fdd7c24f280 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -38,7 +38,7 @@ $hookmanager->initHooks(array('thirdpartiesindex')); $langs->load("companies"); $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; // Security check $result = restrictedArea($user, 'societe', 0, '', '', '', ''); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ca29efbfad8..a1ca78fe67a 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -102,7 +102,7 @@ $search_parent_name = GETPOST('search_parent_name', 'alpha'); $type = GETPOST('type', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $mode = GETPOST("mode", 'alpha'); -$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant +$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant $diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id; diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 0f2bc4d8002..2e3e3ec4532 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -34,24 +34,24 @@ $action = GETPOST('action', 'aZ09'); $langs->load("companies"); // Security check -$id = GETPOST('id')?GETPOST('id', 'int'):GETPOST('socid', 'int'); -if ($user->socid) $id=$user->socid; +$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); +if ($user->socid) $id = $user->socid; $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) $object->fetch($id); -$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartynote','globalcard')); +$hookmanager->initHooks(array('thirdpartynote', 'globalcard')); /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* @@ -60,9 +60,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -$title=$langs->trans("ThirdParty").' - '.$langs->trans("Notes"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notes"); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notes"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notes"); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); if ($object->id > 0) @@ -70,7 +70,7 @@ if ($object->id > 0) /* * Affichage onglets */ - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); @@ -78,9 +78,9 @@ if ($object->id > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - $cssclass='titlefield'; + $cssclass = 'titlefield'; //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; @@ -89,7 +89,7 @@ if ($object->id > 0) print '
      '; print ''; - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index f04459335d5..49cecff76d0 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -34,31 +34,31 @@ $langs->loadLangs(array("companies", "mails", "admin", "other")); $socid = GETPOST("socid", 'int'); $action = GETPOST('action', 'aZ09'); -$contactid = GETPOST('contactid'); // May be an int or 'thirdparty' +$contactid = GETPOST('contactid'); // May be an int or 'thirdparty' $actionid = GETPOST('actionid'); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', '', ''); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield=GETPOST("sortfield", 'alpha'); -$sortorder=GETPOST("sortorder", 'alpha'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="n.daten"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "n.daten"; if (empty($page) || $page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$now=dol_now(); +$now = dol_now(); $object = new Societe($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartynotification','globalcard')); +$hookmanager->initHooks(array('thirdpartynotification', 'globalcard')); @@ -66,13 +66,13 @@ $hookmanager->initHooks(array('thirdpartynotification','globalcard')); * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - $error=0; + $error = 0; // Add a notification if ($action == 'add') @@ -88,7 +88,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -99,7 +99,7 @@ if (empty($reshook)) $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; dol_print_error($db); @@ -110,7 +110,7 @@ if (empty($reshook)) dol_print_error($db); } - if (! $error) + if (!$error) { $db->commit(); } @@ -138,11 +138,11 @@ if (empty($reshook)) $form = new Form($db); $object = new Societe($db); -$result=$object->fetch($socid); +$result = $object->fetch($socid); -$title=$langs->trans("ThirdParty").' - '.$langs->trans("Notification"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notification"); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notification"); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -156,7 +156,7 @@ if ($result > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
      '; @@ -164,7 +164,7 @@ if ($result > 0) print '
      '.$langs->trans('Prefix').''.$object->prefix_comm.'
      '; // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } @@ -178,7 +178,7 @@ if ($result > 0) print ''; } - if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print ''; print ''; -$urlwiki='https://partners.dolibarr.org'; +$urlwiki = 'https://partners.dolibarr.org'; print ''; print ''; -$urlwiki='https://partners.dolibarr.org'; +$urlwiki = 'https://partners.dolibarr.org'; print '
      '.$langs->trans('Prefix').''.$object->prefix_comm.'
      '; print $langs->trans('SupplierCode').''; @@ -225,7 +225,7 @@ if ($result > 0) print ''; print ''; - $param="&socid=".$socid; + $param = "&socid=".$socid; // Line with titles print ''; @@ -236,20 +236,20 @@ if ($result > 0) print_liste_field_titre(''); print "\n"; - $var=false; - $listofemails=$object->thirdparty_and_contact_email_array(); + $var = false; + $listofemails = $object->thirdparty_and_contact_email_array(); if (count($listofemails) > 0) { - $actions=array(); + $actions = array(); // Load array of available notifications - $notificationtrigger=new InterfaceNotification($db); - $listofmanagedeventfornotification=$notificationtrigger->getListOfManagedEvents(); + $notificationtrigger = new InterfaceNotification($db); + $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents(); - foreach($listofmanagedeventfornotification as $managedeventfornotification) + foreach ($listofmanagedeventfornotification as $managedeventfornotification) { - $label=($langs->trans("Notify_".$managedeventfornotification['code'])!="Notify_".$managedeventfornotification['code']?$langs->trans("Notify_".$managedeventfornotification['code']):$managedeventfornotification['label']); - $actions[$managedeventfornotification['rowid']]=$label; + $label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']); + $actions[$managedeventfornotification['rowid']] = $label; } print ''; print ''; print ''; @@ -280,16 +280,16 @@ if ($result > 0) // List of notifications enabled for contacts $sql = "SELECT n.rowid, n.type,"; - $sql.= " a.code, a.label,"; - $sql.= " c.rowid as contactid, c.lastname, c.firstname, c.email"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; - $sql.= " ".MAIN_DB_PREFIX."notify_def as n,"; - $sql.= " ".MAIN_DB_PREFIX."socpeople c"; - $sql.= " WHERE a.rowid = n.fk_action"; - $sql.= " AND c.rowid = n.fk_contact"; - $sql.= " AND c.fk_soc = ".$object->id; + $sql .= " a.code, a.label,"; + $sql .= " c.rowid as contactid, c.lastname, c.firstname, c.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; + $sql .= " ".MAIN_DB_PREFIX."notify_def as n,"; + $sql .= " ".MAIN_DB_PREFIX."socpeople c"; + $sql .= " WHERE a.rowid = n.fk_action"; + $sql .= " AND c.rowid = n.fk_contact"; + $sql .= " AND c.fk_soc = ".$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -318,15 +318,15 @@ if ($result > 0) { $i = 0; - $contactstatic=new Contact($db); + $contactstatic = new Contact($db); while ($i < $num) { $obj = $db->fetch_object($resql); - $contactstatic->id=$obj->contactid; - $contactstatic->lastname=$obj->lastname; - $contactstatic->firstname=$obj->firstname; + $contactstatic->id = $obj->contactid; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = $obj->firstname; print ''; print ''; print ''; print ''; print '';*/ - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } @@ -213,31 +213,31 @@ if ($id > 0 || ! empty($ref)) print '
      '; // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } // additionnal list with adherents of company - if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire) + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $membertypestatic=new AdherentType($db); - $memberstatic=new Adherent($db); + $membertypestatic = new AdherentType($db); + $memberstatic = new Adherent($db); $langs->load("members"); $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; - $sql.= " d.datefin,"; - $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; - $sql.= " t.libelle as type, t.subscription"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE d.fk_soc = ".$id; - $sql.= " AND d.fk_adherent_type = t.rowid"; + $sql .= " d.datefin,"; + $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; + $sql .= " t.libelle as type, t.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE d.fk_soc = ".$id; + $sql .= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); $resql = $db->query($sql); @@ -245,11 +245,11 @@ if ($id > 0 || ! empty($ref)) { $num = $db->num_rows($resql); - if ($num > 0) + if ($num > 0) { $param = ''; - $titre=$langs->trans("MembersListOfTiers"); + $titre = $langs->trans("MembersListOfTiers"); print '
      '; print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, ''); @@ -266,20 +266,20 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", '', $sortfield, $sortorder, 'center '); print "\n"; - $i=0; + $i = 0; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($resql); - $datefin=$db->jdate($objp->datefin); - $memberstatic->id=$objp->rowid; - $memberstatic->ref=$objp->rowid; - $memberstatic->lastname=$objp->lastname; - $memberstatic->firstname=$objp->firstname; - $memberstatic->statut=$objp->statut; - $memberstatic->datefin=$db->jdate($objp->datefin); + $datefin = $db->jdate($objp->datefin); + $memberstatic->id = $objp->rowid; + $memberstatic->ref = $objp->rowid; + $memberstatic->lastname = $objp->lastname; + $memberstatic->firstname = $objp->firstname; + $memberstatic->statut = $objp->statut; + $memberstatic->datefin = $db->jdate($objp->datefin); - $companyname=$objp->company; + $companyname = $objp->company; print ''; @@ -290,18 +290,18 @@ if ($id > 0 || ! empty($ref)) // Lastname print "\n"; // Login print "\n"; // Type - $membertypestatic->id=$objp->type_id; - $membertypestatic->libelle=$objp->type; - $membertypestatic->label=$objp->type; + $membertypestatic->id = $objp->type_id; + $membertypestatic->libelle = $objp->type; + $membertypestatic->label = $objp->type; print ''; print ' @@ -60,7 +60,7 @@ foreach($linkedObjectBlock as $key => $objectlink) if (count($linkedObjectBlock) > 1) { ?> - + diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index 941bf6bb0d3..c12526bbe85 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -25,7 +25,7 @@ */ // Define DOL_DOCUMENT_ROOT -if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..'); +if (!defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..'); require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -35,22 +35,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Avoid warnings with strict mode E_STRICT $conf = new stdClass(); // instantiate $conf explicitely $conf->global = new stdClass(); -$conf->file = new stdClass(); -$conf->db = new stdClass(); +$conf->file = new stdClass(); +$conf->db = new stdClass(); $conf->syslog = new stdClass(); // Force $_REQUEST["logtohtml"] -$_REQUEST["logtohtml"]=1; +$_REQUEST["logtohtml"] = 1; // Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative // et non path absolu. if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) { - $_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"]; + $_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"]; } -$includeconferror=''; +$includeconferror = ''; // Define vars $conffiletoshowshort = "conf.php"; @@ -58,7 +58,7 @@ $conffiletoshowshort = "conf.php"; $conffile = "../conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php"; // For debian/redhat like systems -if (! file_exists($conffile)) +if (!file_exists($conffile)) { $conffile = "/etc/dolibarr/conf.php"; $conffiletoshow = "/etc/dolibarr/conf.php"; @@ -154,8 +154,8 @@ $langs = new Translate('..', $conf); if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); else $langs->setDefaultLang('auto'); -$bc[false]=' class="bg1"'; -$bc[true]=' class="bg2"'; +$bc[false] = ' class="bg1"'; +$bc[true] = ' class="bg2"'; /** @@ -175,10 +175,10 @@ function conf($dolibarr_main_document_root) global $dolibarr_main_db_pass; global $character_set_client; - $return=include_once $dolibarr_main_document_root.'/core/class/conf.class.php'; - if (! $return) return -1; + $return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php'; + if (!$return) return -1; - $conf=new Conf(); + $conf = new Conf(); $conf->db->type = trim($dolibarr_main_db_type); $conf->db->host = trim($dolibarr_main_db_host); $conf->db->port = trim($dolibarr_main_db_port); @@ -186,7 +186,7 @@ function conf($dolibarr_main_document_root) $conf->db->user = trim($dolibarr_main_db_user); $conf->db->pass = trim($dolibarr_main_db_pass); - if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation='utf8_unicode_ci'; + if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; return 1; } diff --git a/htdocs/support/index.php b/htdocs/support/index.php index e4bbfdfa6a2..e6632d2b0e0 100644 --- a/htdocs/support/index.php +++ b/htdocs/support/index.php @@ -28,11 +28,11 @@ // This is a standalone feature with no information from Dolibarr to show // and no database access to do. include_once 'inc.php'; -$uri=preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root); -$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine -if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' -if (! defined('DOL_URL_ROOT')) - define('DOL_URL_ROOT', $pos); // URL racine relative +$uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root); +$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine +if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' +if (!defined('DOL_URL_ROOT')) + define('DOL_URL_ROOT', $pos); // URL racine relative $langs->loadLangs(array("other", $langs->load("help"))); @@ -47,17 +47,17 @@ print $langs->trans("HelpCenterDesc2")."
      \n"; print '
      '; -$homeurl=DOL_URL_ROOT.'/'; -if (GETPOST('dol_hide_toptmenu')) $homeurl.=(strpos($homeurl, '?')===false?'?':'&').'dol_hide_toptmenu=1'; -if (GETPOST('dol_hide_leftmenu')) $homeurl.=(strpos($homeurl, '?')===false?'?':'&').'dol_hide_leftmenu=1'; -if (GETPOST('dol_no_mouse_hover')) $homeurl.=(strpos($homeurl, '?')===false?'?':'&').'dol_no_mouse_hover=1'; -if (GETPOST('dol_use_jmobile')) $homeurl.=(strpos($homeurl, '?')===false?'?':'&').'dol_use_jmobile=1'; +$homeurl = DOL_URL_ROOT.'/'; +if (GETPOST('dol_hide_toptmenu')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_toptmenu=1'; +if (GETPOST('dol_hide_leftmenu')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_leftmenu=1'; +if (GETPOST('dol_no_mouse_hover')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_no_mouse_hover=1'; +if (GETPOST('dol_use_jmobile')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_use_jmobile=1'; print $langs->trans("ToGoBackToDolibarr", $homeurl); print '

      '; -$style1='color: #333344; font-size: 16px; font-weight: bold'; -$style2='color: #5D4455; font-weight: bold;'; +$style1 = 'color: #333344; font-size: 16px; font-weight: bold'; +$style2 = 'color: #5D4455; font-weight: bold;'; print "\n"; print '
      '; @@ -84,17 +84,17 @@ print '
      '; print $form->selectarray("contactid", $listofemails, '', 0, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); @@ -258,7 +258,7 @@ if ($result > 0) print $form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); print ''; - $type=array('email'=>$langs->trans("EMail")); + $type = array('email'=>$langs->trans("EMail")); print $form->selectarray("typeid", $type); print '
      '.$contactstatic->getNomUrl(1); if ($obj->type == 'email') { @@ -342,7 +342,7 @@ if ($result > 0) } print ''; - $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); + $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); print $label; print ''; @@ -415,14 +415,14 @@ if ($result > 0) // List $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,"; - $sql.= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,"; - $sql.= " a.code, a.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; - $sql.= " ".MAIN_DB_PREFIX."notify as n "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid"; - $sql.= " WHERE a.rowid = n.fk_action"; - $sql.= " AND n.fk_soc = ".$object->id; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,"; + $sql .= " a.code, a.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; + $sql .= " ".MAIN_DB_PREFIX."notify as n "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid"; + $sql .= " WHERE a.rowid = n.fk_action"; + $sql .= " AND n.fk_soc = ".$object->id; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -437,9 +437,9 @@ if ($result > 0) } } - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -449,9 +449,9 @@ if ($result > 0) dol_print_error($db); } - $param='&socid='.$object->id; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param = '&socid='.$object->id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print ''; if ($optioncss != '') print ''; @@ -479,7 +479,7 @@ if ($result > 0) { $i = 0; - $contactstatic=new Contact($db); + $contactstatic = new Contact($db); while ($i < $num) { @@ -488,11 +488,11 @@ if ($result > 0) print '
      '; if ($obj->id > 0) { - $contactstatic->id=$obj->id; - $contactstatic->lastname=$obj->lastname; - $contactstatic->firstname=$obj->firstname; + $contactstatic->id = $obj->id; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = $obj->firstname; print $contactstatic->getNomUrl(1); - print $obj->email?' <'.$obj->email.'>':$langs->trans("NoMail"); + print $obj->email ? ' <'.$obj->email.'>' : $langs->trans("NoMail"); } else { @@ -500,7 +500,7 @@ if ($result > 0) } print ''; - $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); + $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); print $label; print ''; diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 198252c3f3a..5ff86ff0064 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -34,30 +34,30 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->loadLangs(array("orders", "companies")); -$id=GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); +$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield=GETPOST("sortfield", 'alpha'); -$sortorder=GETPOST("sortorder", 'alpha'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $id, ''); $object = new Societe($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('contactthirdparty','globalcard')); +$hookmanager->initHooks(array('contactthirdparty', 'globalcard')); /* @@ -98,7 +98,7 @@ elseif ($action == 'swapstatut' && $user->rights->societe->creer) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -134,15 +134,15 @@ elseif ($action == 'setaddress' && $user->rights->societe->creer) * View */ -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $langs->trans("ThirdParty"), $help_url); $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); /* *************************************************************************** */ @@ -151,7 +151,7 @@ $userstatic=new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { @@ -166,7 +166,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
      '; @@ -183,7 +183,7 @@ if ($id > 0 || ! empty($ref)) print yn($object->fournisseur); print '
      '.$langs->trans('Prefix').''.$object->prefix_comm.'
      rowid\">"; - print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); - print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : ''); - print (! empty($companyname) ? dol_trunc($companyname, 32) : ''); + print ((!empty($objp->lastname) || !empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); + print (((!empty($objp->lastname) || !empty($objp->firstname)) && !empty($companyname)) ? ' / ' : ''); + print (!empty($companyname) ? dol_trunc($companyname, 32) : ''); print "".$objp->login."'; print $membertypestatic->getNomUrl(1, 32); diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 9a17ac1e202..11b2d033b69 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -16,7 +16,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -28,23 +28,23 @@ print $langs->trans('SalesRepresentatives'); print ''; -$listsalesrepresentatives=$object->getSalesRepresentatives($user); -$nbofsalesrepresentative=count($listsalesrepresentatives); +$listsalesrepresentatives = $object->getSalesRepresentatives($user); +$nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->login=$val['login']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->statut=$val['statut']; - $userstatic->photo=$val['photo']; - $userstatic->email=$val['email']; - $userstatic->phone=$val['phone']; - $userstatic->job=$val['job']; - $userstatic->entity=$val['entity']; + $userstatic->id = $val['id']; + $userstatic->login = $val['login']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->statut = $val['statut']; + $userstatic->photo = $val['photo']; + $userstatic->email = $val['email']; + $userstatic->phone = $val['phone']; + $userstatic->job = $val['job']; + $userstatic->entity = $val['entity']; print $userstatic->getNomUrl(-1); print ' '; } diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 9d698c7c5f8..a8bca51dda3 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -165,7 +165,7 @@ print ''; dol_fiche_head($head, 'stripeaccount', '', -1); -$stripearrayofwebhookevents=array('account.updated', 'payout.created', 'payout.paid', 'charge.pending', 'charge.refunded', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed', 'payment_method.attached', 'payment_method.updated', 'payment_method.card_automatically_updated', 'payment_method.detached', 'source.chargeable', 'customer.deleted'); +$stripearrayofwebhookevents = array('account.updated', 'payout.created', 'payout.paid', 'charge.pending', 'charge.refunded', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed', 'payment_method.attached', 'payment_method.updated', 'payment_method.card_automatically_updated', 'payment_method.detached', 'source.chargeable', 'customer.deleted'); print ''.$langs->trans("StripeDesc")."
      \n"; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 8f753e3b7b5..f765a2a3ec1 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -97,7 +97,7 @@ if (!$rowid) $param = ''; //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - $param.='&starting_after_'.($page+1).'='.$list->data[($limit-1)]->id; + $param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id; //$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id; $moreforfilter = ''; @@ -138,26 +138,26 @@ if (!$rowid) break; } - if ($charge->refunded=='1') { + if ($charge->refunded == '1') { $status = img_picto($langs->trans("refunded"), 'statut6'); - } elseif ($charge->paid=='1') { + } elseif ($charge->paid == '1') { $status = img_picto($langs->trans((string) $charge->status), 'statut4'); } else { $label = $langs->trans("Message").": ".$charge->failure_message."
      "; - $label.= $langs->trans("Network").": ".$charge->outcome->network_status."
      "; - $label.= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message); + $label .= $langs->trans("Network").": ".$charge->outcome->network_status."
      "; + $label .= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message); $status = $form->textwithpicto(img_picto($langs->trans((string) $charge->status), 'statut8'), $label, -1); } - if ($charge->payment_method_details->type=='card') { + if ($charge->payment_method_details->type == 'card') { $type = $langs->trans("card"); - } elseif ($charge->source->type=='card'){ + } elseif ($charge->source->type == 'card') { $type = $langs->trans("card"); - } elseif ($charge->payment_method_details->type=='three_d_secure'){ + } elseif ($charge->payment_method_details->type == 'three_d_secure') { $type = $langs->trans("card3DS"); - } elseif ($charge->payment_method_details->type=='sepa_debit'){ + } elseif ($charge->payment_method_details->type == 'sepa_debit') { $type = $langs->trans("sepadebit"); - } elseif ($charge->payment_method_details->type=='ideal'){ + } elseif ($charge->payment_method_details->type == 'ideal') { $type = $langs->trans("iDEAL"); } @@ -240,7 +240,7 @@ if (!$rowid) // Origin print "
      "; - if ($charge->metadata->dol_type=="order" || $charge->metadata->dol_type=="commande") { + if ($charge->metadata->dol_type == "order" || $charge->metadata->dol_type == "commande") { $object = new Commande($db); $object->fetch($charge->metadata->dol_id); if ($object->id > 0) { @@ -248,7 +248,7 @@ if (!$rowid) } else { print $FULLTAG; } - } elseif ($charge->metadata->dol_type=="invoice" || $charge->metadata->dol_type=="facture") { + } elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") { print $charge->metadata->dol_type.' '.$charge->metadata->dol_id.' - '; $object = new Facture($db); $object->fetch($charge->metadata->dol_id); diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 28bcf9f3347..a72e5291f58 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -417,7 +417,7 @@ class Stripe extends CommonObject "currency" => $currency_code, "payment_method_types" => array("card"), "description" => $description, - "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) //"save_payment_method" => true, "setup_future_usage" => "on_session", "metadata" => $metadata @@ -764,7 +764,7 @@ class Stripe extends CommonObject { dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); $card = $cu->sources->create($dataforcard); - if (! $card) + if (!$card) { $this->error = 'Creation of card on Stripe has failed'; } @@ -788,7 +788,7 @@ class Stripe extends CommonObject { dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); - if (! $card) + if (!$card) { $this->error = 'Creation of card on Stripe has failed'; } @@ -960,7 +960,7 @@ class Stripe extends CommonObject $charge = \Stripe\Charge::create(array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, @@ -970,7 +970,7 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, @@ -1000,7 +1000,7 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 90533464b7f..10316ec2ece 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -26,17 +26,17 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; //$result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $rowid = GETPOST("rowid", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 978b8ed3d62..59858a69262 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -26,17 +26,17 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; //$result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $rowid = GETPOST("rowid", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); diff --git a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php index 85d01930a7d..132820e8e09 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php @@ -29,13 +29,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='supplier_proposal'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'supplier_proposal'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -52,13 +52,13 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("CommRequests"); +$textobject = $langs->transnoentitiesnoconv("CommRequests"); llxHeader('', $langs->trans("SupplierProposalSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SupplierProposalSetup"), $linkback, 'title_setup'); @@ -99,7 +99,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
      "; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php index 683025ffe86..73ba689f47a 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php @@ -36,14 +36,14 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); -$elementtype='supplier_proposaldet'; //Must be the $table_element of the class that manage extrafield +$elementtype = 'supplier_proposaldet'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -60,11 +60,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("CommRequests"); +$textobject = $langs->transnoentitiesnoconv("CommRequests"); llxHeader('', $langs->trans("SupplierProposalSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SupplierProposalSetup"), $linkback, 'title_setup'); $head = supplier_proposal_admin_prepare_head(); @@ -104,7 +104,7 @@ if ($action == 'create') /* Edition d'un champ optionnel */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
      "; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index df044e66f68..5910f77a819 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -759,8 +759,8 @@ if (empty($reshook)) $pu_ttc, $info_bits, $type, - -1, // rang - 0, // special_code + -1, // rang + 0, // special_code GETPOST('fk_parent_line'), $fournprice, $buyingprice, @@ -768,8 +768,8 @@ if (empty($reshook)) $array_options, $ref_supplier, $fk_unit, - '', // origin - 0, // origin_id + '', // origin + 0, // origin_id $pu_ht_devise); } @@ -1830,25 +1830,25 @@ if ($action == 'create') if ($action == 'statut') { // Form to set proposal accepted/refused - $form_close = ''; - $form_close .= ''; + $form_close = ''; + $form_close .= ''; $form_close .= ''; - if (! empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) $form_close .= '

      '.$langs->trans('SupplierProposalRefFournNotice').'

      '; // TODO Suggest a permanent checkbox instead of option + if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) $form_close .= '

      '.$langs->trans('SupplierProposalRefFournNotice').'

      '; // TODO Suggest a permanent checkbox instead of option $form_close .= ''; - $form_close .= ''; - $form_close .= ''; $form_close .= ''; $form_close .= '
      ' . $langs->trans("CloseAs") . ''; + $form_close .= '
      '.$langs->trans("CloseAs").''; $form_close .= ''; $form_close .= '
      ' . $langs->trans('Note') . '
      '; - $form_close .= ''; - $form_close .= '   '; + $form_close .= ''; + $form_close .= '   '; $form_close .= ' '; $form_close .= '
      '; diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 5f49ebbc427..3fbe3afa021 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -64,16 +64,16 @@ class Supplierproposals extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + if (!DolibarrApiAccess::$user->rights->supplier_proposal->lire) { throw new RestException(401); } $result = $this->supplier_proposal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Supplier Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -105,18 +105,18 @@ class Supplierproposals extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('propal').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -125,23 +125,23 @@ class Supplierproposals extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); @@ -150,12 +150,12 @@ class Supplierproposals extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $propal_static = new SupplierProposal($db); - if($propal_static->fetch($obj->rowid)) { + if ($propal_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($propal_static); } $i++; @@ -164,7 +164,7 @@ class Supplierproposals extends DolibarrApi else { throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No supplier proposal found'); } return $obj_ret; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index adbe97456fa..2f7d4b39cf3 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -596,8 +596,8 @@ class SupplierProposal extends CommonObject //var_dump($this->line->fk_fournprice);exit; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; @@ -724,7 +724,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; + $pu_ht_devise = $tabprice[19]; //Fetch current line from the database and then clone the object and set it in $oldline property $line = new SupplierProposalLine($this->db); @@ -1817,14 +1817,14 @@ class SupplierProposal extends CommonObject $multicurrency_tx = 1; $fk_multicurrency = 0; - if(empty($this->thirdparty)) $this->fetch_thirdparty(); + if (empty($this->thirdparty)) $this->fetch_thirdparty(); $ref_fourn = $product->ref_fourn; - if(empty($ref_fourn)) $ref_fourn = $product->ref_supplier; - if(!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $product->multicurrency_code); + if (empty($ref_fourn)) $ref_fourn = $product->ref_supplier; + if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $product->multicurrency_code); $productsupplier->id = $product->fk_product; - $productsupplier->update_buyprice($product->qty, $product->subprice, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_subprice, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', ''); + $productsupplier->update_buyprice($product->qty, $product->subprice, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_subprice, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', ''); } return 1; @@ -1886,7 +1886,7 @@ class SupplierProposal extends CommonObject include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; $multicurrency = new MultiCurrency($this->db); //need to fetch because empty fk_multicurrency and rate $multicurrency->fetch(0, $product->multicurrency_code); - if(! empty($multicurrency->id)) { + if (!empty($multicurrency->id)) { $values[] = $multicurrency->id; $values[] = "'".$product->multicurrency_code."'"; $values[] = $product->multicurrency_subprice; @@ -1894,14 +1894,14 @@ class SupplierProposal extends CommonObject $values[] = $multicurrency->rate->rate; } else { - for($i = 0; $i < 5; $i++) $values[] = 'NULL'; + for ($i = 0; $i < 5; $i++) $values[] = 'NULL'; } } } $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user'; - if(!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) $sql .= ',fk_multicurrency, multicurrency_code, multicurrency_unitprice, multicurrency_price, multicurrency_tx'; + if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) $sql .= ',fk_multicurrency, multicurrency_code, multicurrency_unitprice, multicurrency_price, multicurrency_tx'; $sql .= ') VALUES ('.implode(',', $values).')'; $resql = $this->db->query($sql); diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index 13a277542b4..43c9b91f563 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array("propal","facture","orders","sendings","companies")); +$langs->loadLangs(array("propal", "facture", "orders", "sendings", "companies")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', ''); $object = new SupplierProposal($db); @@ -143,49 +143,49 @@ if ($id > 0 || !empty($ref)) // Supplier order card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; + $morehtmlref = '
      '; // Ref supplier - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
      '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + $morehtmlref .= '
      '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
      '.$langs->trans('Project') . ' '; + $morehtmlref .= '
      '.$langs->trans('Project').' '; if ($permissiontoedit) { if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
      '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
      '; + $morehtmlref .= '
      '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
      '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 6caa21c7db7..8a6ec8f1bab 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -44,8 +44,8 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$socid=''; -if (! empty($user->socid)) +$socid = ''; +if (!empty($user->socid)) { $socid = $user->socid; } @@ -88,59 +88,59 @@ if ($object->id > 0) dol_fiche_head($head, 'document', $langs->trans('CommRequest'), -1, 'supplier_proposal'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } // Supplier proposal card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; + $morehtmlref = '
      '; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
      '.$langs->trans('Project') . ' '; + $morehtmlref .= '
      '.$langs->trans('Project').' '; if ($user->rights->supplier_proposal->creer) { if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
      '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
      '; + $morehtmlref .= '
      '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
      '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index 094258ff348..8c1d007e39a 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -28,18 +28,18 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('supplier_proposal', 'compta')); -$id=GETPOST('id', 'int'); -$socid=GETPOST('socid', 'int'); +$id = GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int'); // Security check -if (! empty($user->socid)) $socid=$user->socid; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'supplier_proposal', $id); @@ -62,50 +62,50 @@ $head = supplier_proposal_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans('CommRequest'), -1, 'supplier_proposal'); // Supplier proposal card -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
      '; +$morehtmlref = '
      '; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty -$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); +$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
      '.$langs->trans('Project') . ' '; + $morehtmlref .= '
      '.$langs->trans('Project').' '; if ($user->rights->supplier_proposal->creer) { if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
      '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
      '; + $morehtmlref .= '
      '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
      '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } -$morehtmlref.='
      '; +$morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index a3e58312e11..aaf40288e15 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -29,18 +29,18 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('supplier_proposal', 'compta', 'bills')); $id = GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal'); $object = new SupplierProposal($db); @@ -64,68 +64,68 @@ llxHeader('', $langs->trans('CommRequest'), 'EN:Ask_Price_Supplier|FR:Demande_de $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($mesg) print $mesg; - $now=dol_now(); + $now = dol_now(); if ($object->fetch($id, $ref)) { $object->fetch_thirdparty(); $societe = new Societe($db); - if ( $societe->fetch($object->socid) ) + if ($societe->fetch($object->socid)) { $head = supplier_proposal_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans('CommRequest'), -1, 'supplier_proposal'); // Supplier proposal card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
      '; + $morehtmlref = '
      '; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
      '.$langs->trans('Project') . ' '; + $morehtmlref .= '
      '.$langs->trans('Project').' '; if ($user->rights->supplier_proposal->creer) { if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
      '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
      '; + $morehtmlref .= '
      '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
      '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
      '; + $morehtmlref .= '
      '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index 6c4bea3ba8b..c4891f52f81 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -33,14 +33,14 @@ global $user; $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?>
      trans("SupplierProposal"); ?>
      trans("Total"); ?> '; print ''; print '
      '; -$urlwiki='https://wiki.dolibarr.org'; -if (preg_match('/fr/i', $langs->defaultlang)) $urlwiki='https://wiki.dolibarr.org/index.php/Accueil'; -if (preg_match('/es/i', $langs->defaultlang)) $urlwiki='https://wiki.dolibarr.org/index.php/Portada'; +$urlwiki = 'https://wiki.dolibarr.org'; +if (preg_match('/fr/i', $langs->defaultlang)) $urlwiki = 'https://wiki.dolibarr.org/index.php/Accueil'; +if (preg_match('/es/i', $langs->defaultlang)) $urlwiki = 'https://wiki.dolibarr.org/index.php/Portada'; print '
      '.$langs->trans("ForDocumentationSeeWiki", $urlwiki, $urlwiki); print '
      '; -$urlforum='https://www.dolibarr.org/forum/'; -$urlforumlocal='https://www.dolibarr.org/forum/'; -if (preg_match('/fr/i', $langs->defaultlang)) $urlforumlocal='https://www.dolibarr.fr/forum/'; -if (preg_match('/es/i', $langs->defaultlang)) $urlforumlocal='https://www.dolibarr.es/foro/'; -if (preg_match('/it/i', $langs->defaultlang)) $urlforumlocal='http://www.dolibarr.it/forum/'; -if (preg_match('/gr/i', $langs->defaultlang)) $urlforumlocal='https://www.dolibarr.gr/forum/'; +$urlforum = 'https://www.dolibarr.org/forum/'; +$urlforumlocal = 'https://www.dolibarr.org/forum/'; +if (preg_match('/fr/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.fr/forum/'; +if (preg_match('/es/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.es/foro/'; +if (preg_match('/it/i', $langs->defaultlang)) $urlforumlocal = 'http://www.dolibarr.it/forum/'; +if (preg_match('/gr/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.gr/forum/'; print '
      '.$langs->trans("ForAnswersSeeForum", $urlforumlocal, $urlforumlocal).'
      '; if ($urlforumlocal != $urlforum) print ''.$urlforum.''; print '
      '; @@ -121,7 +121,7 @@ print '
      '; print '
      '; print ''; print '
      '; @@ -155,7 +155,7 @@ print '
      '; print '
      '; print ''; print ''; print ''; print "\n"; -if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ +if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { print ''; } -if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ +if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
      '; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index bdc40934a16..bf5c4671b13 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -161,20 +161,20 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; + $var = true; - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file; // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -185,9 +185,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print '
      '."\n"; @@ -211,17 +211,17 @@ foreach ($dirmodels as $reldir) $invoice->pos_source = 1; // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
      '; - $nextval=$module->getNextValue($mysoc, $invoice); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
      '; + $nextval = $module->getNextValue($mysoc, $invoice); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
      '; + $htmltooltip .= $nextval.'
      '; } else { - $htmltooltip.=$langs->trans($module->error).'
      '; + $htmltooltip .= $langs->trans($module->error).'
      '; } } diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 89cf13956ac..f3b5ba15716 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -24,13 +24,13 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../../main.inc.php'; // Load $user and permissions +require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $category = GETPOST('category', 'alpha'); @@ -49,7 +49,7 @@ if (empty($user->rights->takepos->run)) { if ($action == 'getProducts') { $object = new Categorie($db); - if ($category=="supplements") $category=$conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY; + if ($category == "supplements") $category = $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY; $result = $object->fetch($category); if ($result > 0) { @@ -78,7 +78,7 @@ elseif ($action == 'search' && $term != '') { //$result = $object->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID); $arrayofcateg = $object->get_full_arbo('product', $conf->global->TAKEPOS_ROOT_CATEGORY_ID, 1); if (is_array($arrayofcateg) && count($arrayofcateg) > 0) { - foreach($arrayofcateg as $val) + foreach ($arrayofcateg as $val) { $filteroncategids .= ($filteroncategids ? ', ' : '').$val['id']; } @@ -88,7 +88,7 @@ elseif ($action == 'search' && $term != '') { $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { - $sql.= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.'))'; + $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.'))'; } $sql .= ' AND tosell = 1'; $sql .= natural_search(array('ref', 'label', 'barcode'), $term); @@ -123,7 +123,7 @@ elseif ($action == 'search' && $term != '') { $printer->pulse(); $printer->close(); } -} elseif ($action == "printinvoiceticket" && $term != '' && $id > 0 && ! empty($user->rights->facture->lire)) { +} elseif ($action == "printinvoiceticket" && $term != '' && $id > 0 && !empty($user->rights->facture->lire)) { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $printer = new dolReceiptPrinter($db); @@ -134,7 +134,7 @@ elseif ($action == 'search' && $term != '') { $ret = $printer->sendToPrinter($object, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term}); } } elseif ($action == 'getInvoice') { - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); if ($id > 0) { diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index ef0ff2ca4f4..5193e95c7c5 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -32,9 +32,9 @@ if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; // Load $user and permissions -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; global $mysoc; @@ -115,15 +115,15 @@ if ($action == "addnote") echo ' load_cache_vatrates("'" . $mysoc->country_code . "'"); + $num = $form->load_cache_vatrates("'".$mysoc->country_code."'"); if ($num > 0) { print '

      '; - print $langs->trans('VAT') . ' : '; + print $langs->trans('VAT').' : '; foreach ($form->cache_vatrates as $rate) { - print ''; + print ''; } } } diff --git a/htdocs/takepos/genimg/index.php b/htdocs/takepos/genimg/index.php index faec3ab5088..a5686054193 100644 --- a/htdocs/takepos/genimg/index.php +++ b/htdocs/takepos/genimg/index.php @@ -17,20 +17,20 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../../main.inc.php'; // Load $user and permissions +require '../../main.inc.php'; // Load $user and permissions $id = GETPOST('id', 'int'); $w = GETPOST('w', 'int'); $h = GETPOST('h', 'int'); -$query= GETPOST('query', 'alpha'); +$query = GETPOST('query', 'alpha'); @@ -38,7 +38,7 @@ $query= GETPOST('query', 'alpha'); * View */ -if ($query=="cat") +if ($query == "cat") { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; @@ -47,36 +47,36 @@ if ($query=="cat") $result = $object->fetch($id); $upload_dir = $conf->categorie->multidir_output[$object->entity]; - $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/"; + $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/"; $dir = $upload_dir.'/'.$pdir; foreach ($object->liste_photos($dir) as $key => $obj) { if ($obj['photo_vignette']) { - $filename=$obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } - $file=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename); + $file = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename); header('Location: '.$file); exit; } header('Location: ../../public/theme/common/nophoto.png'); } -elseif ($query=="pro") +elseif ($query == "pro") { require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; $objProd = new Product($db); $objProd->fetch($id); - $image=$objProd->show_photos('product', $conf->product->multidir_output[$entity], 'small', 1); + $image = $objProd->show_photos('product', $conf->product->multidir_output[$entity], 'small', 1); preg_match('@src="([^"]+)"@', $image, $match); $file = array_pop($match); - if ($file=="") header('Location: ../../public/theme/common/nophoto.png'); + if ($file == "") header('Location: ../../public/theme/common/nophoto.png'); else header('Location: '.$file.'&cache=1'); } else diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2ac1a57ef0b..2e85f8c2afa 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -330,7 +330,7 @@ if ($action == "addline") if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) { foreach ($invoice->lines as $line) { if ($line->product_ref == $prod->ref) { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty+1, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + 1, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); if ($result < 0) { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } else { @@ -416,7 +416,7 @@ if ($action == "delete") { $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".$placeid; $resql2 = $db->query($sql); $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; - $sql.= " WHERE ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql .= " WHERE ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql3 = $db->query($sql); if ($resql1 && $resql2 && $resql3) @@ -727,23 +727,23 @@ $( document ).ready(function() { order('datec', 'ASC'); + $sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%'"; + $sql .= $db->order('datec', 'ASC'); $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { echo '$("#customerandsales").append(\''; - if ($placeid==$obj->rowid) echo ""; + if ($placeid == $obj->rowid) echo ""; echo 'ref)); + $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref)); echo $num_sale; - if (str_replace("-", "", $num_sale)>$max_sale) $max_sale=str_replace("-", "", $num_sale); + if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale); echo '\\\';Refresh();">'.date('H:i', strtotime($obj->datec)); - if ($placeid==$obj->rowid) echo ""; + if ($placeid == $obj->rowid) echo ""; echo '\');'; } echo '$("#customerandsales").append(\'\');'; } else { dol_print_error($db); @@ -779,26 +779,26 @@ $( document ).ready(function() { if ($result > 0) { $adh->ref = $adh->getFullName($langs); - $s.= $adh->getFullName($langs); - $s.= ' - '.$adh->type; + $s .= $adh->getFullName($langs); + $s .= ' - '.$adh->type; if ($adh->datefin) { - $s.= '
      '.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); + $s .= '
      '.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { - $s.= " ".img_warning($langs->trans("Late")); + $s .= " ".img_warning($langs->trans("Late")); } } else { - $s.= '
      '.$langs->trans("SubscriptionNotReceived"); - if ($adh->statut > 0) $s.= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated + $s .= '
      '.$langs->trans("SubscriptionNotReceived"); + if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } } else { - $s.= '
      '.$langs->trans("ThirdpartyNotLinkedToMember"); + $s .= '
      '.$langs->trans("ThirdpartyNotLinkedToMember"); } - $s.= ''; + $s .= ''; } ?> $("#moreinfo").html(''); diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php index ae5081ca891..7be5ee85938 100644 --- a/htdocs/takepos/reduction.php +++ b/htdocs/takepos/reduction.php @@ -82,8 +82,8 @@ if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { $htmlReductionPercent = ''; $htmlReductionAmount = ''; } else { - $htmlReductionPercent = $langs->trans('ReductionShort') . '
      %'; - $htmlReductionAmount = $langs->trans('ReductionShort') . '
      ' . $langs->trans('Amount'); + $htmlReductionPercent = $langs->trans('ReductionShort').'
      %'; + $htmlReductionAmount = $langs->trans('ReductionShort').'
      '.$langs->trans('Amount'); } ?> @@ -213,11 +213,11 @@ if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/theme/eldy/doc/badges.php b/htdocs/theme/eldy/doc/badges.php index 97cc8edb461..52a422a053c 100644 --- a/htdocs/theme/eldy/doc/badges.php +++ b/htdocs/theme/eldy/doc/badges.php @@ -1,11 +1,11 @@ - status- + status-
       
      -<span class="badge badge-status" >status</span>
      +<span class="badge badge-status" >status</span>
       
       		
      @@ -170,7 +170,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; Dark - status + status @@ -187,7 +187,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; <span class="badge badge-pill badge-light">Light</span> <span class="badge badge-pill badge-dark">Dark</span> -<span class="badge badge-pill badge-status" >status</span> +<span class="badge badge-pill badge-status" >status</span> @@ -209,7 +209,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; - + @@ -226,7 +226,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; <span class="badge badge-dot badge-light"></span> <span class="badge badge-dot badge-dark"></span> -<span class="badge badge-dot badge-status" ></span> +<span class="badge badge-dot badge-status" ></span> @@ -255,7 +255,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; Light Dark - status + status @@ -270,7 +270,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; <a href="#" class="badge badge-light">Light</a> <a href="#" class="badge badge-dark">Dark</a> -<a href="#" class="badge badge-status" >status</a> +<a href="#" class="badge badge-status" >status</a> diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index e930eef3f03..49f910f50da 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -1,5 +1,5 @@ +if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> /*
      '; diff --git a/htdocs/takepos/admin/orderprinters.php b/htdocs/takepos/admin/orderprinters.php index 94a4ee8a85e..566f18ac1a4 100644 --- a/htdocs/takepos/admin/orderprinters.php +++ b/htdocs/takepos/admin/orderprinters.php @@ -26,7 +26,7 @@ * \brief Home page of category area */ -require '../../main.inc.php'; // Load $user and permissions +require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -34,32 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->loadLangs(array("main"), "categories", "takepos", "printing"); -if (! $user->rights->categorie->lire) accessforbidden(); +if (!$user->rights->categorie->lire) accessforbidden(); -$id=GETPOST('id', 'int'); -$type=(GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); -$catname=GETPOST('catname', 'alpha'); -$action=GETPOST('action', 'alpha'); -$printer1=GETPOST('printer1', 'alpha'); -$printer2=GETPOST('printer2', 'alpha'); +$id = GETPOST('id', 'int'); +$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); +$catname = GETPOST('catname', 'alpha'); +$action = GETPOST('action', 'alpha'); +$printer1 = GETPOST('printer1', 'alpha'); +$printer2 = GETPOST('printer2', 'alpha'); -if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility /* * Actions */ -if ($action=="SavePrinter1"){ - $printedcategories=";"; - if (is_array($printer1)) foreach ($printer1 as $cat){ - $printedcategories=$printedcategories.$cat.";"; +if ($action == "SavePrinter1") { + $printedcategories = ";"; + if (is_array($printer1)) foreach ($printer1 as $cat) { + $printedcategories = $printedcategories.$cat.";"; } dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity); } -if ($action=="SavePrinter2"){ - $printedcategories=";"; - if (is_array($printer2)) foreach ($printer2 as $cat){ - $printedcategories=$printedcategories.$cat.";"; +if ($action == "SavePrinter2") { + $printedcategories = ";"; + if (is_array($printer2)) foreach ($printer2 as $cat) { + $printedcategories = $printedcategories.$cat.";"; } dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity); } @@ -72,18 +72,18 @@ if ($action=="SavePrinter2"){ $categstatic = new Categorie($db); $form = new Form($db); -if ($type == Categorie::TYPE_PRODUCT) { $title=$langs->trans("ProductsCategoriesArea"); $typetext='product'; } -elseif ($type == Categorie::TYPE_SUPPLIER) { $title=$langs->trans("SuppliersCategoriesArea"); $typetext='supplier'; } -elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCategoriesArea"); $typetext='customer'; } -elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; } -elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; } -elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='bank_account'; } -elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; } -elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } -else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; } +if ($type == Categorie::TYPE_PRODUCT) { $title = $langs->trans("ProductsCategoriesArea"); $typetext = 'product'; } +elseif ($type == Categorie::TYPE_SUPPLIER) { $title = $langs->trans("SuppliersCategoriesArea"); $typetext = 'supplier'; } +elseif ($type == Categorie::TYPE_CUSTOMER) { $title = $langs->trans("CustomersCategoriesArea"); $typetext = 'customer'; } +elseif ($type == Categorie::TYPE_MEMBER) { $title = $langs->trans("MembersCategoriesArea"); $typetext = 'member'; } +elseif ($type == Categorie::TYPE_CONTACT) { $title = $langs->trans("ContactsCategoriesArea"); $typetext = 'contact'; } +elseif ($type == Categorie::TYPE_ACCOUNT) { $title = $langs->trans("AccountsCategoriesArea"); $typetext = 'bank_account'; } +elseif ($type == Categorie::TYPE_PROJECT) { $title = $langs->trans("ProjectsCategoriesArea"); $typetext = 'project'; } +elseif ($type == Categorie::TYPE_USER) { $title = $langs->trans("UsersCategoriesArea"); $typetext = 'user'; } +else { $title = $langs->trans("CategoriesArea"); $typetext = 'unknown'; } -$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); -$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); +$arrayofjs = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); +$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss); @@ -109,19 +109,19 @@ print '

      '; $cate_arbo = $categstatic->get_full_arbo($typetext); // Define fulltree array -$fulltree=$cate_arbo; +$fulltree = $cate_arbo; // Define data (format for treeview) -$data=array(); -$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); -foreach($fulltree as $key => $val) +$data = array(); +$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); +foreach ($fulltree as $key => $val) { - $categstatic->id=$val['id']; - $categstatic->ref=$val['label']; - $categstatic->color=$val['color']; - $categstatic->type=$type; - $li=$categstatic->getNomUrl(1, '', 60); - $desc=dol_htmlcleanlastbr($val['description']); + $categstatic->id = $val['id']; + $categstatic->ref = $val['label']; + $categstatic->color = $val['color']; + $categstatic->type = $type; + $li = $categstatic->getNomUrl(1, '', 60); + $desc = dol_htmlcleanlastbr($val['description']); $data[] = array( 'rowid'=>$val['rowid'], @@ -135,15 +135,15 @@ foreach($fulltree as $key => $val) print ''; print ''; -$nbofentries=(count($data) - 1); +$nbofentries = (count($data) - 1); print ''; if ($nbofentries > 0) { print ''; } @@ -165,15 +165,15 @@ print '

      '; print '
      '.$langs->trans("Printer").' 1'; print '
      '; print ''; foreach ($data as $row) { - if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) $checked='checked'; else $checked=''; - if ($row["fk_menu"]==0) print ''.$row["label"].'
      '; + if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = ''; + if ($row["fk_menu"] == 0) print ''.$row["label"].'
      '; } print '
      '; print ''; -$nbofentries=(count($data) - 1); +$nbofentries = (count($data) - 1); print ''; if ($nbofentries > 0) { print ''; } diff --git a/htdocs/takepos/admin/other.php b/htdocs/takepos/admin/other.php index 564b637d8e1..cbb22c94f90 100644 --- a/htdocs/takepos/admin/other.php +++ b/htdocs/takepos/admin/other.php @@ -22,11 +22,11 @@ * \brief Setup page for TakePos module */ require '../../main.inc.php'; // Load $user and permissions -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/pdf.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/takepos.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; // If socid provided by ajax company selector if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { @@ -42,8 +42,8 @@ $langs->loadLangs(array("admin", "cashdesk")); global $db; -$sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement"; -$sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")"; +$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; +$sql .= " WHERE entity IN (".getEntity('c_paiement').")"; $sql .= " AND active = 1"; $sql .= " ORDER BY libelle"; $resql = $db->query($sql); @@ -88,7 +88,7 @@ if (GETPOST('action', 'alpha') == 'set') { $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, 255, 'facturedet', 0, 0, '', '', 0, '', 0, 1); } - dol_syslog("admin/cashdesk: level " . GETPOST('level', 'alpha')); + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); if (!$res > 0) $error++; @@ -108,16 +108,16 @@ if (GETPOST('action', 'alpha') == 'set') { llxHeader('', $langs->trans("CashDeskSetup")); -$linkback = '' . $langs->trans("BackToModuleList") . ''; -print load_fiche_titre($langs->trans("CashDeskSetup") . ' (TakePOS)', $linkback, 'title_setup'); +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup'); $head = takepos_prepare_head(); dol_fiche_head($head, 'other', 'TakePOS', -1); print '
      '; // Mode -print ''; -print ''; +print ''; +print ''; print ''; @@ -125,17 +125,17 @@ print '
      '; // Marketplace print "
      '.$langs->trans("Printer").' 2'; print '
      '; print ''; foreach ($data as $row) { - if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) $checked='checked'; else $checked=''; - if ($row["fk_menu"]==0) print ''.$row["label"].'
      '; + if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = ''; + if ($row["fk_menu"] == 0) print ''.$row["label"].'
      '; } print '
      \n"; -print '' . "\n"; -print ''; -print ''; +print ''."\n"; +print ''; +print ''; print ''; $url = 'https://www.dolistore.com/45-pos'; -print '' . "\n"; -print ''; -print ''; -print ''; +print ''."\n"; +print ''; +print ''; +print ''; print ''; print "
      ' . $langs->trans("WebSiteDesc") . '' . $langs->trans("URL") . '
      '.$langs->trans("WebSiteDesc").''.$langs->trans("URL").'
      ' . $langs->trans("DolistorePosCategory") . '' . $url . '
      '.$langs->trans("DolistorePosCategory").''.$url.'
      \n"; @@ -149,17 +149,17 @@ print '
      '; // Support print "\n"; -print '' . "\n"; +print ''."\n"; print ''; -print ''; +print ''; print ''; $url = 'http://www.takepos.com'; -print '' . "\n"; -print ''; +print ''."\n"; +print ''; print ''; -print ''; +print ''; print ''; print "
      TakePOS Support' . $langs->trans("URL") . ''.$langs->trans("URL").'
      TakePOS original developers' . $url . ''.$url.'
      \n"; diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index d50faa480cb..79d6277c761 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -153,7 +153,7 @@ print '
      '.$langs->trans("Parameters").''.$langs->trans("Value").'
      '; print $langs->trans("IPAddress").' ('.$langs->trans("TakeposConnectorNecesary").')'; print ''; @@ -161,7 +161,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ print '
      '; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
      '.$langs->trans($tmp).'
      '; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '